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
570
Ruby Quiz
at 学生エンジニア限定LT大会
pocke
October 08, 2017
Tweet
Share
More Decks by pocke
See All by pocke
The path to memory reduction in RBS
pocke
0
12
RBSのメモリ使用量改善への道
pocke
1
8
Community-driven RBS repository
pocke
2
1k
Active Record Query Quiz
pocke
1
1.3k
Let's write RBS!
pocke
1
4.7k
RBS and Rails, Present and Future
pocke
1
1.3k
The newsletter of RBS updates
pocke
1
3.3k
kwargs warning → Sentry
pocke
0
300
Ruboty and SKI
pocke
0
170
Other Decks in Programming
See All in Programming
どうして手を動かすよりもチーム内のコードレビューを優先するべきなのか
okashoi
3
870
為你自己學 Python
eddie
0
520
ゼロからの、レトロゲームエンジンの作り方
tokujiros
3
1.1k
AWSのLambdaで PHPを動かす選択肢
rinchoku
2
390
毎日13時間もかかるバッチ処理をたった3日で60%短縮するためにやったこと
sho_ssk_
1
550
テストコード書いてみませんか?
onopon
2
340
traP の部内 ISUCON とそれを支えるポータル / PISCON Portal
ikura_hamu
0
180
Оптимизируем производительность блока Казначейство
lamodatech
0
950
.NETでOBS Studio操作してみたけど…… / Operating OBS Studio by .NET
skasweb
0
120
[JAWS-UG横浜 #80] うわっ…今年のServerless アップデート、少なすぎ…?
maroon1st
0
100
QA環境で誰でも自由自在に現在時刻を操って検証できるようにした話
kalibora
1
140
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
1.4k
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
3
180
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
BBQ
matthewcrist
85
9.4k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Become a Pro
speakerdeck
PRO
26
5.1k
Designing for Performance
lara
604
68k
YesSQL, Process and Tooling at Scale
rocio
170
14k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.2k
Designing for humans not robots
tammielis
250
25k
A Tale of Four Properties
chriscoyier
157
23k
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