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
Equality in Ruby
Search
Romain Sempé
August 14, 2012
Programming
0
58
Equality in Ruby
Romain Sempé
August 14, 2012
Tweet
Share
More Decks by Romain Sempé
See All by Romain Sempé
Are you happy with your code quality?
rsempe
0
80
Scan security of your Rails app with Brakeman
rsempe
2
190
Other Decks in Programming
See All in Programming
STUNMESH-go: Wireguard NAT穿隧工具的源起與介紹
tjjh89017
0
370
エンジニアのための”最低限いい感じ”デザイン入門
shunshobon
0
110
Dart 参戦!!静的型付き言語界の隠れた実力者
kno3a87
0
200
技術的負債で信頼性が限界だったWordPress運用をShifterで完全復活させた話
rvirus0817
1
1.7k
Gemini CLIの"強み"を知る! Gemini CLIとClaude Codeを比較してみた!
kotahisafuru
3
1.1k
兎に角、コードレビュー
mitohato14
0
110
新世界の理解
koriym
0
130
Google I/O recap web編 大分Web祭り2025
kponda
0
2.8k
『リコリス・リコイル』に学ぶ!! 〜キャリア戦略における計画的偶発性理論と変わる勇気の重要性〜
wanko_it
1
520
実践!App Intents対応
yuukiw00w
1
270
自作OSでDOOMを動かしてみた
zakki0925224
1
1.3k
Understanding Kotlin Multiplatform
l2hyunwoo
0
260
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3k
We Have a Design System, Now What?
morganepeng
53
7.7k
How GitHub (no longer) Works
holman
314
140k
Documentation Writing (for coders)
carmenintech
73
5k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
358
30k
Art, The Web, and Tiny UX
lynnandtonic
301
21k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Scaling GitHub
holman
462
140k
Visualization
eitanlees
146
16k
Why Our Code Smells
bkeepers
PRO
338
57k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Transcript
Equality in Ruby Romain Sempé @rsempe
Equality or Identity? Equality: Different objects that represent the
same value. Identity: Different variables that refer to the same object.
Equal yes! But in what sense? What equality methods
should we use? == eql? equal? === =~
== Test only if the objects have the same value.
eql? Test if the objects have the same value and
the same type.
equal? Test if the objects have the same value, the
same type and are the same instance in memory.
=== Same as == but for case statements. One operator
depending on the context of the comparison (Class, Range, Regexp, …).
=~ Interesting with the Regexp class. It’s an alias to
the match method.
Conclusion == is great most of the time
eql? and equal? can be useful to be more precise Elegant case statements with === Concise test for Regexp with =~ Only one identity operator: equal?