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
600
Ruby Quiz
at 学生エンジニア限定LT大会
pocke
October 08, 2017
Tweet
Share
More Decks by pocke
See All by pocke
プログラミングで遊ぶ
pocke
0
50
Witchcraft for Memory
pocke
1
3.9k
The path to memory reduction in RBS
pocke
0
46
RBSのメモリ使用量改善への道
pocke
1
50
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
Other Decks in Programming
See All in Programming
SODA - FACT BOOK(JP)
sodainc
1
9k
ボトムアップの生成AI活用を推進する社内AIエージェント開発
aku11i
0
1.3k
業務でAIを使いたい話
hnw
0
210
Introducing RemoteCompose: break your UI out of the app sandbox.
camaelon
2
160
O Que É e Como Funciona o PHP-FPM?
marcelgsantos
0
240
ネストしたdata classの面倒な更新にさようなら!Lensを作って理解するArrowのOpticsの世界
shiita0903
1
180
CSC305 Lecture 11
javiergs
PRO
0
320
TransformerからMCPまで(現代AIを理解するための羅針盤)
mickey_kubo
7
5.8k
オープンソースソフトウェアへの解像度🔬
utam0k
18
3.2k
品質ワークショップをやってみた
nealle
0
660
Amazon Verified Permissions実践入門 〜Cedar活用とAppSync導入事例/Practical Introduction to Amazon Verified Permissions
fossamagna
2
110
Register is more than clipboard
satorunooshie
1
170
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Speed Design
sergeychernyshev
32
1.2k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Navigating Team Friction
lara
190
15k
A designer walks into a library…
pauljervisheath
209
24k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
116
20k
Making the Leap to Tech Lead
cromwellryan
135
9.6k
The Cost Of JavaScript in 2023
addyosmani
55
9.1k
Stop Working from a Prison Cell
hatefulcrawdad
272
21k
The Invisible Side of Design
smashingmag
302
51k
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