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 3
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Erik Berlin
December 03, 2015
Programming
0
750
Ruby Trivia 3
Presented at the Berlin Ruby User Group (RUG::B) on November 5, 2015.
Erik Berlin
December 03, 2015
Tweet
Share
More Decks by Erik Berlin
See All by Erik Berlin
Enumerator::Lazy
sferik
2
620
The Value of Being Lazy
sferik
3
850
Ruby Trivia 2
sferik
0
810
Ruby Trivia
sferik
2
1.3k
💀 Symbols
sferik
5
2k
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
米国のサイバーセキュリティタイムラインと見る Goの暗号パッケージの進化
tomtwinkle
1
200
PostgreSQL を使った快適な go test 環境を求めて
otakakot
0
310
AWS re:Invent 2025参加 直前 Seattle-Tacoma Airport(SEA)におけるハードウェア紛失インシデントLT
tetutetu214
2
130
エージェント開発初心者の僕がエージェントを作った話と今後やりたいこと
thasu0123
0
160
朝日新聞のデジタル版を支えるGoバックエンド ー価値ある情報をいち早く確実にお届けするために
junkiishida
1
250
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
1
1.1k
ふん…おもしれぇ Parser。RubyKaigi 行ってやるぜ
aki_pin0
0
110
Package Management Learnings from Homebrew
mikemcquaid
0
280
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
190
AIプロダクト時代のQAエンジニアに求められること
imtnd
1
480
Geminiの機能を調べ尽くしてみた
naruyoshimi
0
170
AI巻き込み型コードレビューのススメ
nealle
2
2.3k
Featured
See All Featured
Visualization
eitanlees
150
17k
Facilitating Awesome Meetings
lara
57
6.8k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
1.9k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
110
Optimising Largest Contentful Paint
csswizardry
37
3.6k
Testing 201, or: Great Expectations
jmmastey
46
8.1k
Side Projects
sachag
455
43k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
130
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Building an army of robots
kneath
306
46k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
Transcript
Ruby Trivia 3
What is the value of the global variable $_? Question
1:
The String last read by gets. Answer 1:
How can you list all global variables? Bonus Question:
How can you list all global variables? Bonus Question: Answer:
Use the Kernel#global_variables method.
How many global variables does Ruby define? global_variables.count Bonus Question:
How many global variables does Ruby define? global_variables.count Bonus Question:
Answer: 54.
What does Ruby’s -n switch do? Question 2:
Causes Ruby to assume the following loop around your script,
which makes it iterate over file name arguments like sed -n or awk. while gets ... end Answer 2:
What does Ruby’s -p switch do? Bonus Question:
Acts like the -n switch, but prints the value of
variable $_ at the each end of the loop. For example: ruby -p -e '$_.tr! "a-z", "A-Z"' < file Bonus Question:
What thread-local variable can only store four possible values? Question
3:
What thread-local variable can only store four possible values? Question
3: Hint #1: Those values are 0, 1, 2, and 3.
What thread-local variable can only store four possible values? Question
3: Hint #1: Those values are 0, 1, 2, and 3. Hint #2: The value is 0 by default and can only increase.
$SAFE Answer 3: Trick question because it looks like a
global variable, even though it behaves like a thread-local variable.
$SAFE Answer 3: There used to be $SAFE = 4
but it was removed in Ruby 2.1. Supposedly, it was only ever used by one company in Japan.
How can you check if an object is trusted? Bonus
Question:
How can you check if an object is trusted? Bonus
Question: Answer: Use the Kernel#tainted? method.
What happens if you do this? module Kernel def tainted?
return false end end Question 4:
The tainted? method will always return false, but Ruby will
still track tainted state via an internal FL_TAINT flag. Answer 4:
How can you mark a tainted object as safe? Question
5:
Kernel#untaint a.k.a. Kernel#trust $SAFE = 1 foo = gets.trust eval(foo)
Answer 5:
Thanks for playing! Follow @sferik on Twitter for more Ruby
trivia and practica.