Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Ruby Quiz
Search
pocke
October 08, 2017
Programming
1
530
Ruby Quiz
at 学生エンジニア限定LT大会
pocke
October 08, 2017
Tweet
Share
More Decks by pocke
See All by pocke
Active Record Query Quiz
pocke
1
950
Let's write RBS!
pocke
1
3.9k
RBS and Rails, Present and Future
pocke
1
1.1k
The newsletter of RBS updates
pocke
1
2.9k
kwargs warning → Sentry
pocke
0
230
Ruboty and SKI
pocke
0
130
Regression test for RuboCop
pocke
0
110
ruby-jp
pocke
1
1.7k
Suppress Warning
pocke
2
970
Other Decks in Programming
See All in Programming
DocC Tutorial と TCA におけるテスト機能の紹介
kalupas226
1
330
設計の知識と技能で駆動するソフトウェア開発
masuda220
PRO
18
10k
PHP 8.3で追加されたjson_validate()を徹底的に深掘りしてみよう
mashirou1234
1
720
LPIXEL×CADDi_kaerururu
kaerururu
3
300
ファイル先頭の use の意味、説明できますか? 〜PHP の namespace と autoloading の関係を正しく理解しよう〜 / namespace and autoloading in php
okashoi
2
470
導入から5年が経って見えた Datadog APM 運用の課題
bgpat
2
540
自作ソフト(VMagicMirror)がVRMA対応してる話+実装のTips
bakudreameater
0
110
Creating Retro-Style Photos Using Swift
ski
1
340
Swiftの型推論を学ぼう | Let's Learn About Type Inference in Swift
omochi
2
520
BuefyのMaintainerを引き継いだ件
kikuomax
0
520
Crafting a Own PHP - ウキウキ手作りミニマリストPHP
uzulla
4
1.1k
Building a Smaller App Binary
kateinoigakukun
2
200
Featured
See All Featured
JazzCon 2018 Closing Keynote - Leadership for the Reluctant Leader
reverentgeek
178
11k
The Brand Is Dead. Long Live the Brand.
mthomps
48
21k
Principles of Awesome APIs and How to Build Them.
keavy
119
16k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
12
1.4k
10 Git Anti Patterns You Should be Aware of
lemiorhan
644
57k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3k
How to name files
jennybc
62
92k
Bootstrapping a Software Product
garrettdimon
PRO
302
110k
Building Applications with DynamoDB
mza
88
5.6k
Writing Fast Ruby
sferik
619
59k
How STYLIGHT went responsive
nonsquared
92
4.7k
Automating Front-end Workflow
addyosmani
1353
200k
Transcript
Ruby Quiz Oct. 8, 2017 第4回 学生エンジニア限定LT大会
I have only 5 minutes, so I'll speak very fast.
Self introduction • Pocke • Actcat, Inc. / SideCI •
RuboCop' s core developer • Student at The Open University of Japan
SideCI
Automated Code Review as a Service
Please access here! https://sideci.com
Ruby Quiz
Question
Do you write Ruby?
Ruby Quiz • You are a Ruby interpreter. ◦ You
are a parse.y. ◦ You are a YARV. • You execute ruby code, and you output result.
Quiz 1
Q. What does the code output? p(??) p(%_?_)
Answer p(??) # => "?" p(%_?_) # => "?"
Why?
A. Why does it output "?"? p(??) p(%_?_) %<any character>…<any
character> is a string literal. e.g.) %_?_ == "?" , %!???! == "???" ?_ is a character literal. e.g.) ?_ == "_" , ?? == "?"
Quiz 2
Q. What does the code output? p(????::?:) p(% %s% %%%%)
Answer p(????::?:) # => ":" p(% %s% %%%%) # =>
"%"
Why????
Answer p(????::?:) p(% %s% %%%%) 1. ?? is "?" 2.
? is a part of conditional op 3. ?: is ":" 4. : is a part of conditional op 5. ?: is ":" "?" ? ":" : ":" 1. % %s% is "%s%" 2. % is a format op(Like sprintf) 3. %%% is "" sprintf("%s%", "")
Quiz 3
Q. What does the code output? a = ["1","2","3"] a&.map(&:to_i)&.&([1])
Answer a = ["1","2","3"] a&.map(&:to_i)&.&([1]) # => [1]
Why?????
Answer a = ["1","2","3"] a&.map(&:to_i)&.&([1]) # => [1] &. is
a safe navigation op(nil guard). &:to_i is an implicit to_proc op. A safe navigation op & is an intersection op call (like [1,2,3] & [1])
Conclusion
• We can write tricky code in Ruby. ◦ Very
fun!!! Thank you for listening! Conclusion