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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Erik Berlin
November 05, 2015
Programming
0
810
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
630
Ruby Trivia 3
sferik
0
750
The Value of Being Lazy
sferik
3
850
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
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
1.1k
Rethinking API Platform Filters
vinceamstoutz
0
2.5k
脱 雰囲気実装!AgentCoreを良い感じにWEBアプリケーションに組み込むために
takuyay0ne
3
410
AI 開発合宿を通して得た学び
niftycorp
PRO
0
180
ロボットのための工場に灯りは要らない
watany
12
3.2k
Migration to Signals, Signal Forms, Resource API, and NgRx Signal Store @Angular Days 03/2026 Munich
manfredsteyer
PRO
0
180
Strategy for Finding a Problem for OSS: With Real Examples
kibitan
0
120
今からFlash開発できるわけないじゃん、ムリムリ! (※ムリじゃなかった!?)
arkw
0
160
最初からAWS CDKで技術検証してもいいんじゃない?
akihisaikeda
4
180
Everything Claude Code OSS詳細 — 5層構造の中身と導入方法
targe
0
160
Reactive ❤️ Loom: A Forbidden Love Story
franz1981
2
190
車輪の再発明をしよう!PHP で実装して学ぶ、Web サーバーの仕組みと HTTP の正体
h1r0
2
440
Featured
See All Featured
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.2k
The Limits of Empathy - UXLibs8
cassininazir
1
270
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
330
Thoughts on Productivity
jonyablonski
75
5.1k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
160
A Soul's Torment
seathinner
5
2.5k
GraphQLとの向き合い方2022年版
quramy
50
14k
Technical Leadership for Architectural Decision Making
baasie
3
300
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
0
470
A Tale of Four Properties
chriscoyier
163
24k
30 Presentation Tips
portentint
PRO
1
260
Paper Plane (Part 1)
katiecoart
PRO
0
6.1k
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.