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
560
Ruby Quiz
at 学生エンジニア限定LT大会
pocke
October 08, 2017
Tweet
Share
More Decks by pocke
See All by pocke
Community-driven RBS repository
pocke
2
830
Active Record Query Quiz
pocke
1
1.2k
Let's write RBS!
pocke
1
4.5k
RBS and Rails, Present and Future
pocke
1
1.2k
The newsletter of RBS updates
pocke
1
3.2k
kwargs warning → Sentry
pocke
0
280
Ruboty and SKI
pocke
0
160
Regression test for RuboCop
pocke
0
180
ruby-jp
pocke
1
2k
Other Decks in Programming
See All in Programming
"Swarming" をコンセプトに掲げるアジャイルチームのベストプラクティス
boykush
2
250
DjangoNinjaで高速なAPI開発を実現する
masaya00
0
510
Cloud Adoption Framework にみる組織とクラウド導入戦略
tomokusaba
2
460
GrafanaのHTTP API を眺めてみよう
rinchoku
0
100
[PHPカンファレンス沖縄2024]「無理なくできるだけ安全に」テストもないレガシーコードをリファクタリングするテクニック
ikezoemakoto
3
130
What is TDD?
urakawa_jinsei
1
220
Progressive Web Apps for Rails developers
siaw23
2
550
UnJSで簡単に始めるCLIツール開発 / cli-tool-development-with-unjs
aoseyuu
2
290
モジュラモノリス、その前に / Modular monolith, before that
euglena1215
6
690
2024-10-02 dev2next - Application Observability like you've never heard before
jonatan_ivanov
0
180
データサイエンスのフルサイクル開発を実現する機械学習パイプライン
xcnkx
2
500
CSC509 Lecture 04
javiergs
PRO
0
140
Featured
See All Featured
Music & Morning Musume
bryan
46
6.1k
We Have a Design System, Now What?
morganepeng
49
7.2k
A Tale of Four Properties
chriscoyier
156
22k
Optimizing for Happiness
mojombo
375
69k
GraphQLとの向き合い方2022年版
quramy
43
13k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.8k
The Cult of Friendly URLs
andyhume
77
6k
How to Ace a Technical Interview
jacobian
275
23k
Making the Leap to Tech Lead
cromwellryan
131
8.8k
Typedesign – Prime Four
hannesfritz
39
2.3k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
7.5k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.5k
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