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
650
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Ruby Quiz
at 学生エンジニア限定LT大会
pocke
October 08, 2017
More Decks by pocke
See All by pocke
New "Type" system on PicoRuby
pocke
2
1.7k
プログラミングで遊ぶ
pocke
0
150
Witchcraft for Memory
pocke
1
6.7k
The path to memory reduction in RBS
pocke
0
97
RBSのメモリ使用量改善への道
pocke
1
88
Community-driven RBS repository
pocke
2
1.7k
Active Record Query Quiz
pocke
1
1.7k
Let's write RBS!
pocke
1
5.5k
RBS and Rails, Present and Future
pocke
1
1.4k
Other Decks in Programming
See All in Programming
Deep dive into the select statement (GopherCon UK)
jespino
0
160
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
740
リアルな遅延を測る仕様
kota_yata
1
130
Webエンジニアなのにブラウザの仕組みがわからないので、Pythonで自作してみた
tatsuki12
4
1.2k
コンパウンドプロダクト開発のためのローカルプロセスマネージャー再発明 #layerxgo
izumin5210
0
530
komatsuna「分散システムにおけるバグ分析手法」
komatsunaqa
0
290
AIと壁打ちしながら進めるコスト管理
fufuhu
2
1.8k
片田舎のおっさん、 Swift Buildのダイアモンド問題解決の不具合修正PRを出すが、解決方法がキャッシュをしないようにすることであり、ビルド時間が伸びると言われてマージされないので高速化もする/swiftbuild
yimajo
0
320
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
130
プロポーザルを書いてもらう
pvcresin
0
590
ソフトウェアエンジニアにとっての生成AI - 特性を知って使い倒す / generative ai for software enginner
kishida
7
2.2k
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.5k
Featured
See All Featured
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
230
The untapped power of vector embeddings
frankvandijk
2
1.8k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
310
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
420
Chasing Engaging Ingredients in Design
codingconduct
0
290
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
880
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
670
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
520
Paper Plane (Part 1)
katiecoart
PRO
1
10k
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