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.1k
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
400
Ruby Trivia 3
sferik
0
560
The Value of Being Lazy
sferik
3
600
Ruby Trivia 2
sferik
0
620
💀 Symbols
sferik
5
1.6k
Content Negotiation for REST APIs
sferik
8
830
Writing Fast Ruby
sferik
622
60k
Mutation Testing with Mutant
sferik
5
1k
Other Decks in Programming
See All in Programming
初心者のためのRubyKaigi入門/RubyKaigi Introduction
a_matsuda
10
1.9k
Let's learn code review
riofujimon
2
640
株式会社ゼネテック
genetec
0
120
AmperとFleetを使ったAndroidアプリ
yoppie
0
300
Sheets API使ってみた
toshi0383
2
180
slow types ってなんだろう?
karad
0
210
RustでAWS Lambda functionをいい感じに書く
taiki45
2
150
slog登場に伴うloggerの取り回し手法の見直し / kamakura.go #6
arthur1
0
120
Findy - エンジニア向け会社紹介 / Findy Letter for Engineers
findyinc
2
74k
RubyGems on ruby.wasm
kateinoigakukun
0
110
Documentation testsの恩恵 / Documentation testing benefits
ssssota
1
560
ts-morphを使ってコードリプレイスとASTへのハードルを下げる!
nyawach
5
320
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
36
2.1k
The Pragmatic Product Professional
lauravandoore
26
5.9k
The Invisible Customer
myddelton
114
12k
YesSQL, Process and Tooling at Scale
rocio
165
13k
Bash Introduction
62gerente
605
210k
4 Signs Your Business is Dying
shpigford
176
21k
Happy Clients
brianwarren
92
6.4k
10 Git Anti Patterns You Should be Aware of
lemiorhan
649
58k
The Art of Programming - Codeland 2020
erikaheidi
43
12k
Pencils Down: Stop Designing & Start Developing
hursman
117
11k
A Philosophy of Restraint
colly
197
16k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.1k
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.