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
59
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
81
Scan security of your Rails app with Brakeman
rsempe
2
190
Other Decks in Programming
See All in Programming
Foundation Modelsを実装日本語学習アプリを作ってみた!
hypebeans
0
130
20251016_Rails News ~Rails 8.1の足音を聴く~
morimorihoge
3
860
登壇は dynamic! な営みである / speech is dynamic
da1chi
0
390
AIのバカさ加減に怒る前にやっておくこと
blueeventhorizon
0
120
Devoxx BE - Local Development in the AI Era
kdubois
0
150
CSC305 Lecture 12
javiergs
PRO
0
240
SODA - FACT BOOK(JP)
sodainc
1
8.9k
Amazon Verified Permissions実践入門 〜Cedar活用とAppSync導入事例/Practical Introduction to Amazon Verified Permissions
fossamagna
2
100
SwiftDataを使って10万件のデータを読み書きする
akidon0000
0
250
Server Side Kotlin Meetup vol.16: 内部動作を理解して ハイパフォーマンスなサーバサイド Kotlin アプリケーションを書こう
ternbusty
3
260
Reactive Thinking with Signals and the Resource API
manfredsteyer
PRO
0
120
社会人になっても趣味開発を続けたい! / traPavilion
mazrean
1
110
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
303
21k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
A Tale of Four Properties
chriscoyier
161
23k
Practical Orchestrator
shlominoach
190
11k
Context Engineering - Making Every Token Count
addyosmani
8
310
Bash Introduction
62gerente
615
210k
Product Roadmaps are Hard
iamctodd
PRO
55
11k
Six Lessons from altMBA
skipperchong
29
4k
A better future with KSS
kneath
239
18k
Typedesign – Prime Four
hannesfritz
42
2.8k
How to Think Like a Performance Engineer
csswizardry
27
2.2k
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?