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
410
Ruby Trivia 3
sferik
0
570
The Value of Being Lazy
sferik
3
610
Ruby Trivia 2
sferik
0
630
💀 Symbols
sferik
5
1.7k
Content Negotiation for REST APIs
sferik
8
850
Writing Fast Ruby
sferik
623
60k
Mutation Testing with Mutant
sferik
5
1k
Other Decks in Programming
See All in Programming
Exploring the OpenTelemetry Client Library for Go
akarin
0
250
My favorite script, "dsl.rb"
yui_knk
2
580
PandasAI:生成AIがデータ分析業務にもたらすパラダイムシフト
negi111111
4
210
A Sighting of filterA in Typelevel Rite of Passage
philipschwarz
PRO
0
180
플레이어 SDK 개발자의 Kotlin Multiplatform 도입기
mojs
0
140
ゼロからつくる 2D物理シミュレーション ~物理現象をコードに落とし込む方法~
infiniteloop_inc
0
110
Platform Engineering with Spring Boot
thombergs
0
410
RubyKaigi Effect 2023, and ...
tagomoris
1
520
エンジニア向け 株式会社バックテック 会社紹介資料 / for Engineers
backtech
1
290
Deriving derived state: derivedStateOf explained (dcSF 24)
zachklipp
1
160
DroidKnights 2024 - Compose UI 컴포넌트 설계와 테스트
wisemuji
0
570
バリデーション付きフォームを宣言的に実装する / Declaratively Implementing a Form with Validation
studio_rookery
0
260
Featured
See All Featured
How GitHub (no longer) Works
holman
305
140k
4 Signs Your Business is Dying
shpigford
176
21k
Practical Orchestrator
shlominoach
184
9.8k
The Language of Interfaces
destraynor
151
23k
A Modern Web Designer's Workflow
chriscoyier
689
190k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
247
20k
Clear Off the Table
cherdarchuk
87
310k
Imperfection Machines: The Place of Print at Facebook
scottboms
261
12k
Designing with Data
zakiwarfel
96
4.9k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
5
250
The Cult of Friendly URLs
andyhume
74
5.8k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
27
2.4k
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.