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 Trivia
Search
Erik Berlin
October 01, 2015
Programming
2
1.2k
Ruby Trivia
Presented at the Berlin Ruby User Group (RUG::B) on October 1, 2015.
Erik Berlin
October 01, 2015
Tweet
Share
More Decks by Erik Berlin
See All by Erik Berlin
Enumerator::Lazy
sferik
1
500
Ruby Trivia 3
sferik
0
640
The Value of Being Lazy
sferik
3
690
Ruby Trivia 2
sferik
0
680
💀 Symbols
sferik
5
1.8k
Content Negotiation for REST APIs
sferik
8
920
Writing Fast Ruby
sferik
627
61k
Mutation Testing with Mutant
sferik
5
1k
Other Decks in Programming
See All in Programming
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
330
Macとオーディオ再生 2024/11/02
yusukeito
0
370
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.3k
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.1k
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
170
Amazon Qを使ってIaCを触ろう!
maruto
0
400
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
170
受け取る人から提供する人になるということ
little_rubyist
0
230
詳細解説! ArrayListの仕組みと実装
yujisoftware
0
580
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.1k
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
Featured
See All Featured
Being A Developer After 40
akosma
86
590k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Statistics for Hackers
jakevdp
796
220k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
How STYLIGHT went responsive
nonsquared
95
5.2k
How to Ace a Technical Interview
jacobian
276
23k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
A Tale of Four Properties
chriscoyier
156
23k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Transcript
Ruby Trivia
In Ruby, a dash may not be used in a
variable name… …but before Ruby 2.1, one variable was allowed to be named with a dash. What was it called? Question 1:
In Ruby, a dash may not be used in a
variable name… …but before Ruby 2.1, one variable was allowed to be named with a dash. What was it called? Hint: It’s a global variable. Question 1:
$- Answer 1:
Why can’t variable names contain dashes? Bonus Question:
Why can’t variable names contain dashes? Bonus Question: Answer: Because
the Ruby parser can’t distinguish it from the minus (-) operator between two variables (e.g. forty-two).
Ruby may define a special File object in the first
file it interprets. What is it called? What does it do? Question 2:
Ruby may define a special File object in the first
file it interprets. What is it called? Question 2: Hint: When you call read, it reads the file, starting after __END__
DATA Answer 2:
What happens if you call: DATA.rewind before DATA.read Bonus Question:
What happens if you call: DATA.rewind before DATA.read Bonus Question:
Answer: It reads the entire file, including the source code.
The following line of code is valid Ruby syntax: a
= true && return But this line of code is not: a = return && true What is the error message? Question 3:
void value expression Answer 3:
When you convert the range: (1..3).to_a You get the array:
[1, 2, 3] What is the result of: (3..1).to_a Question 4:
[] Answer 4:
What method would need to be added to the Range
interface to make descending sequences possible? Bonus Question:
What method would need to be added to the Range
interface to make descending sequences possible? Bonus Question: Answer: pred (the opposite of succ).
What Ruby class mixes-in Comparable but doesn’t define the spaceship
(<=>) operator? Question 5:
What Ruby class mixes-in Comparable but doesn’t define the spaceship
(<=>) operator? Hint: It’s a descendant of Numeric. Question 5:
Complex Answer 5:
Thanks for playing! Follow @sferik on Twitter for more Ruby
trivia and practica.