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 2
Search
Erik Berlin
November 05, 2015
Programming
0
780
Ruby Trivia 2
Presented at the Berlin Ruby User Group (RUG::B) on November 5, 2015.
Erik Berlin
November 05, 2015
Tweet
Share
More Decks by Erik Berlin
See All by Erik Berlin
Enumerator::Lazy
sferik
2
590
Ruby Trivia 3
sferik
0
720
The Value of Being Lazy
sferik
3
810
Ruby Trivia
sferik
2
1.3k
💀 Symbols
sferik
5
1.9k
Content Negotiation for REST APIs
sferik
8
1k
Writing Fast Ruby
sferik
630
62k
Mutation Testing with Mutant
sferik
5
1.1k
Other Decks in Programming
See All in Programming
Blazing Fast UI Development with Compose Hot Reload (droidcon London 2025)
zsmb
0
480
MCPサーバー「モディフィウス」で変更容易性の向上をスケールする / modifius
minodriven
7
1.2k
Pythonに漸進的に型をつける
nealle
1
160
Designing Repeatable Edits: The Architecture of . in Vim
satorunooshie
0
250
エンジニアに事業やプロダクトを理解してもらうためにやってること
murabayashi
0
140
Migration to Signals, Resource API, and NgRx Signal Store
manfredsteyer
PRO
0
160
Swift Concurrency 年表クイズ
omochi
3
220
contribution to astral-sh/uv
shunsock
0
590
組織もソフトウェアも難しく考えない、もっとシンプルな考え方で設計する #phpconfuk
o0h
PRO
9
3.4k
Kotlin + Power-Assert 言語組み込みならではのAssertion Library採用と運用ベストプラクティス by Kazuki Matsuda/Gen-AX
kazukima
0
100
CSC509 Lecture 11
javiergs
PRO
0
290
퇴근 후 1억이 거래되는 서비스 만들기 | 내가 AI를 사용하는 방법
maryang
2
500
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
97
6.3k
Balancing Empowerment & Direction
lara
5
730
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
15k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.1k
Done Done
chrislema
186
16k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
Automating Front-end Workflow
addyosmani
1371
200k
Become a Pro
speakerdeck
PRO
29
5.6k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
Transcript
Ruby Trivia 2
What is the return value of Ruby’s method visibility keywords?
private, public, protected Question 1:
self Answer 1: Ruby’s method visibility keywords can be used
as r-values.
Given a button method that takes an argument and a
block, which of these are valid Ruby? button "string" { |n| n } button "string" do |n| n end button ["string"] { |n| n } button ["string"] do |n| n end Question 2:
All except: button("string") { |n| n } Answer 2:
How could this line be fixed? button("string") { |n| n
} Bonus Question:
How could this line be fixed? button("string") { |n| n
} Bonus Question: Answer: Add parentheses around the argument.
What is the result of this line: a Hash with
a String key, a Hash with a Symbol key, or a SyntaxError? {"key": "What happens?"} Question 3:
a Hash with a Symbol key* Answer 3: *In Ruby
2.2 and later. In earlier versions, it raises a SyntaxError.
What is the value of each argument? def foo(*w, a:
7, **t) puts "w: #{w}, a: #{a}, t: #{t}" end foo({a: 1, b: 2, "c" => 3, d: 4}) Question 4:
w: [{"c" => 3}] a: 1 t: {:b => 2,
:d => 4} Answer 4:
What happens if you add a positional argument to the
end? def foo(*w, a: 7, **t) puts "w: #{w}, a: #{a}, t: #{t}" end foo({a: 1, b: 2, "c" => 3, d: 4}, 5) Bonus Question:
What happens if you add a positional argument to the
end? w: [{:a=>1, :b=>2, "c"=>3, :d=>4}, 5] a: 7 t: {} Bonus Question:
When you inspect Object.new, Ruby outputs something like: #<Object: 0x00c1a551f1ab1e>
What are the properties and significance of this hex number? Question 5:
1. It’s the object’s address in memory. 2. It’s always
even. 3. It’s double the object’s object_id. Answer 5:
Answer 5:
Thanks for playing! Follow @sferik on Twitter for more Ruby
trivia and practica.