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
Erik Berlin
December 03, 2015
Programming
770
0
Share
Ruby Trivia 3
Presented at the Berlin Ruby User Group (RUG::B) on November 5, 2015.
Erik Berlin
December 03, 2015
More Decks by Erik Berlin
See All by Erik Berlin
Enumerator::Lazy
sferik
2
650
The Value of Being Lazy
sferik
3
870
Ruby Trivia 2
sferik
0
830
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.2k
Other Decks in Programming
See All in Programming
AgentCore Optimizationを始めよう!
licux
4
280
Oxlintはいかにしてtsgolintのlint ruleを呼び出しているのか
syumai
1
470
20年以上続くプロダクトでも使い続けられる静的解析ツールを求めて
matsuo_atsushi
0
160
AlarmKitで明後日起きれるアラームアプリを作る
trickart
0
140
UaaL×Androidアプリのメモリ計測 — Memory Profilerの先へ
rio432
0
170
AIエージェントと協働するCLI開発 — BunとOpenClawで学んだこと
yoshikouki
1
210
TypeSpec で繋ぐ複数プロダクトの型安全
maroon8021
1
230
Spec-Driven Development with AI Agents (Workshop, May 2026)
antonarhipov
4
430
Agent Skills を社内で育てる仕組み作り
jackchuka
1
2.4k
実践ハーネスエンジニアリング:ステアリングループを実例から読み解く / Practical Harness Engineering: Understanding Steering Loops Through Real-World Examples
nrslib
6
6.2k
ローカルLLMでどこまでコードが書けるか / How much code can be written on a local LLM
kishida
2
410
Skillは並べた。動かなかった。契約で繋いだ。— 65個のSkillから、自走する開発サイクルへ
junholee
0
710
Featured
See All Featured
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
230
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
150
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
380
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.9k
Building AI with AI
inesmontani
PRO
1
1k
How GitHub (no longer) Works
holman
316
150k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.7k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
We Have a Design System, Now What?
morganepeng
55
8.1k
Design in an AI World
tapps
1
210
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.