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
590
Ruby Quiz
at 学生エンジニア限定LT大会
pocke
October 08, 2017
Tweet
Share
More Decks by pocke
See All by pocke
Witchcraft for Memory
pocke
1
3.7k
The path to memory reduction in RBS
pocke
0
45
RBSのメモリ使用量改善への道
pocke
1
47
Community-driven RBS repository
pocke
2
1.4k
Active Record Query Quiz
pocke
1
1.5k
Let's write RBS!
pocke
1
5.1k
RBS and Rails, Present and Future
pocke
1
1.4k
The newsletter of RBS updates
pocke
1
3.4k
kwargs warning → Sentry
pocke
0
340
Other Decks in Programming
See All in Programming
iOSでSVG画像を扱う
kishikawakatsumi
0
150
Go言語の特性を活かした公式MCP SDKの設計
hond0413
1
440
他言語経験者が Golangci-lint を最初のコーディングメンターにした話 / How Golangci-lint Became My First Coding Mentor: A Story from a Polyglot Programmer
uma31
0
330
EMこそClaude Codeでコード調査しよう
shibayu36
0
320
「ちょっと古いから」って避けてた技術書、今だからこそ読もう
mottyzzz
11
7k
Vueのバリデーション、結局どれを選べばいい? ― 自作バリデーションの限界と、脱却までの道のり ― / Which Vue Validation Library Should We Really Use? The Limits of Self-Made Validation and How I Finally Moved On
neginasu
1
150
PHPに関数型の魂を宿す〜PHP 8.5 で実現する堅牢なコードとは〜 #phpcon_hiroshima / phpcon-hiroshima-2025
shogogg
1
320
技術的負債の正体を知って向き合う
irof
0
230
Devoxx BE - Local Development in the AI Era
kdubois
0
130
モテるデスク環境
mozumasu
3
1k
フロントエンド開発のためのブラウザ組み込みAI入門
masashi
7
3.4k
Pythonに漸進的に型をつける
nealle
1
110
Featured
See All Featured
RailsConf 2023
tenderlove
30
1.3k
Documentation Writing (for coders)
carmenintech
75
5.1k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.7k
The Invisible Side of Design
smashingmag
302
51k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.2k
Producing Creativity
orderedlist
PRO
347
40k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.5k
Being A Developer After 40
akosma
91
590k
YesSQL, Process and Tooling at Scale
rocio
173
15k
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