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.3k
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
2
560
Ruby Trivia 3
sferik
0
690
The Value of Being Lazy
sferik
3
760
Ruby Trivia 2
sferik
0
740
💀 Symbols
sferik
5
1.9k
Content Negotiation for REST APIs
sferik
8
980
Writing Fast Ruby
sferik
628
61k
Mutation Testing with Mutant
sferik
5
1.1k
Other Decks in Programming
See All in Programming
GoのWebAssembly活用パターン紹介
syumai
2
910
Perplexity Slack Botを作ってAI活用を進めた話 / AI Engineering Summit プレイベント
n3xem
0
340
Babylon.js 8.0のアプデ情報を 軽率にキャッチアップ / catch-up-babylonjs-8
drumath2237
0
120
衛星の軌道をWeb地図上に表示する
sankichi92
0
260
データベースコネクションプール(DBCP)の変遷と理解
fujikawa8
0
190
ts-morph実践:型を利用するcodemodのテクニック
ypresto
1
580
UPDATEがシステムを複雑にする? イミュータブルデータモデルのすすめ
shimomura
0
490
バリデーションライブラリ徹底比較
nayuta999999
1
570
コンポーネントライブラリで実現する、アクセシビリティの正しい実装パターン
schktjm
1
710
単体テストの始め方/作り方
toms74209200
0
350
Perlで痩せる
yuukis
1
670
Interface vs Types ~型推論が過多推論~
hirokiomote
1
240
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.6k
Rebuilding a faster, lazier Slack
samanthasiow
81
9k
Speed Design
sergeychernyshev
30
980
What's in a price? How to price your products and services
michaelherold
245
12k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
6
670
GraphQLとの向き合い方2022年版
quramy
46
14k
Balancing Empowerment & Direction
lara
1
100
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.7k
A designer walks into a library…
pauljervisheath
205
24k
How STYLIGHT went responsive
nonsquared
100
5.6k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.2k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
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.