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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
pocke
October 08, 2017
Programming
620
1
Share
Ruby Quiz
at 学生エンジニア限定LT大会
pocke
October 08, 2017
More Decks by pocke
See All by pocke
プログラミングで遊ぶ
pocke
0
110
Witchcraft for Memory
pocke
1
5.3k
The path to memory reduction in RBS
pocke
0
61
RBSのメモリ使用量改善への道
pocke
1
70
Community-driven RBS repository
pocke
2
1.6k
Active Record Query Quiz
pocke
1
1.6k
Let's write RBS!
pocke
1
5.3k
RBS and Rails, Present and Future
pocke
1
1.4k
The newsletter of RBS updates
pocke
1
3.5k
Other Decks in Programming
See All in Programming
AI時代の脳疲弊と向き合う ~言語学としてのPHP~
sakuraikotone
1
1.8k
車輪の再発明をしよう!PHP で実装して学ぶ、Web サーバーの仕組みと HTTP の正体
h1r0
2
480
PHP 7.4でもOpenTelemetryゼロコード計装がしたい! / PHPerKaigi 2026
arthur1
1
460
モダンOBSプラグイン開発
umireon
0
190
最初からAWS CDKで技術検証してもいいんじゃない?
akihisaikeda
4
180
一度始めたらやめられない開発効率向上術 / Findy あなたのdotfilesを教えて!
k0kubun
3
2.7k
ファインチューニングせずメインコンペを解く方法
pokutuna
0
250
メッセージングを利用して時間的結合を分離しよう #phperkaigi
kajitack
3
530
ネイティブアプリとWebフロントエンドのAPI通信ラッパーにおける共通化の勘所
suguruooki
0
230
Smarter Angular mit Transformers.js & Prompt API
christianliebel
PRO
1
110
Symfonyの特性(設計思想)を手軽に活かす特性(trait)
ickx
0
110
Nuxt Server Components
wattanx
0
230
Featured
See All Featured
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
190
What does AI have to do with Human Rights?
axbom
PRO
1
2.1k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.1k
How to Talk to Developers About Accessibility
jct
2
170
Darren the Foodie - Storyboard
khoart
PRO
3
3.1k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.3k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
800
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
Automating Front-end Workflow
addyosmani
1370
200k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
620
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
160
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.9k
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