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
810
0
Share
Ruby Trivia 2
Presented at the Berlin Ruby User Group (RUG::B) on November 5, 2015.
Erik Berlin
November 05, 2015
More Decks by Erik Berlin
See All by Erik Berlin
Enumerator::Lazy
sferik
2
630
Ruby Trivia 3
sferik
0
750
The Value of Being Lazy
sferik
3
860
Ruby Trivia
sferik
2
1.4k
💀 Symbols
sferik
5
2k
Content Negotiation for REST APIs
sferik
8
1.1k
Writing Fast Ruby
sferik
630
63k
Mutation Testing with Mutant
sferik
5
1.1k
Other Decks in Programming
See All in Programming
安いハードウェアでVulkan
fadis
1
920
へんな働き方
yusukebe
6
2.9k
Codex CLIのSubagentsによる並列API実装 / Parallel API Implementation with Codex CLI Subagents
takatty
2
850
今こそ押さえておきたい アマゾンウェブサービス(AWS)の データベースの基礎 おもクラ #6版
satoshi256kbyte
1
230
今からFlash開発できるわけないじゃん、ムリムリ! (※ムリじゃなかった!?)
arkw
0
180
Coding at the Speed of Thought: The New Era of Symfony Docker
dunglas
0
4.6k
Codex CLI でつくる、Issue から merge までの開発フロー
amata1219
0
320
年間50登壇、単著出版、雑誌寄稿、Podcast出演、YouTube、CM、カンファレンス主催……全部やってみたので面白さ等を比較してみよう / I’ve tried them all, so let’s compare how interesting they are.
nrslib
4
720
野球解説AI Agentを開発してみた - 2026/02/27 LayerX社内LT会資料
shinyorke
PRO
0
400
「接続」—パフォーマンスチューニングの最後の一手 〜点と点を結ぶ、その一瞬のために〜
kentaroutakeda
5
2.5k
PDI: Como Alavancar Sua Carreira e Seu Negócio
marcelgsantos
0
100
Goの型安全性で実現する複数プロダクトの権限管理
ishikawa_pro
2
1.4k
Featured
See All Featured
Statistics for Hackers
jakevdp
799
230k
The Cost Of JavaScript in 2023
addyosmani
55
9.8k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
Facilitating Awesome Meetings
lara
57
6.8k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.3k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
170
Java REST API Framework Comparison - PWX 2021
mraible
34
9.2k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
150
Context Engineering - Making Every Token Count
addyosmani
9
800
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
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.