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
GoのWebAssembly活用パターン紹介
syumai
3
10k
Beyond Portability: Live Migration for Evolving WebAssembly Workloads
chikuwait
0
390
プロダクト志向ってなんなんだろうね
righttouch
PRO
0
150
Bytecode Manipulation 으로 생산성 높이기
bigstark
2
370
Rubyでやりたい駆動開発 / Ruby driven development
chobishiba
1
320
iOSアプリ開発で 関数型プログラミングを実現する The Composable Architectureの紹介
yimajo
2
210
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
200
イベントストーミング図からコードへの変換手順 / Procedure for Converting Event Storming Diagrams to Code
nrslib
1
300
なぜ適用するか、移行して理解するClean Architecture 〜構造を超えて設計を継承する〜 / Why Apply, Migrate and Understand Clean Architecture - Inherit Design Beyond Structure
seike460
PRO
1
660
Haskell でアルゴリズムを抽象化する / 関数型言語で競技プログラミング
naoya
17
4.9k
Cline指示通りに動かない? AI小説エージェントで学ぶ指示書の書き方と自動アップデートの仕組み
kamomeashizawa
1
570
『自分のデータだけ見せたい!』を叶える──Laravel × Casbin で複雑権限をスッキリ解きほぐす 25 分
akitotsukahara
1
470
Featured
See All Featured
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
5
210
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
4 Signs Your Business is Dying
shpigford
184
22k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
657
60k
Unsuck your backbone
ammeep
671
58k
Scaling GitHub
holman
459
140k
YesSQL, Process and Tooling at Scale
rocio
173
14k
The Straight Up "How To Draw Better" Workshop
denniskardys
233
140k
Practical Orchestrator
shlominoach
188
11k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
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?