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
さようなら Date。 ようこそTemporal! 3年間先行利用して得られた知見の共有
8beeeaaat
3
1.5k
testingを眺める
matumoto
1
140
スケールする組織の実現に向けた インナーソース育成術 - ISGT2025
teamlab
PRO
2
170
JSONataを使ってみよう Step Functionsが楽しくなる実践テクニック #devio2025
dafujii
1
640
Zendeskのチケットを Amazon Bedrockで 解析した
ryokosuge
3
320
MCPとデザインシステムに立脚したデザインと実装の融合
yukukotani
4
1.5k
FindyにおけるTakumi活用と脆弱性管理のこれから
rvirus0817
0
540
個人軟體時代
ethanhuang13
0
330
AI時代のUIはどこへ行く?
yusukebe
18
9.1k
Tool Catalog Agent for Bedrock AgentCore Gateway
licux
7
2.5k
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
3
310
RDoc meets YARD
okuramasafumi
4
170
Featured
See All Featured
Facilitating Awesome Meetings
lara
55
6.5k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.9k
Visualization
eitanlees
148
16k
Mobile First: as difficult as doing things right
swwweet
224
9.9k
Site-Speed That Sticks
csswizardry
10
820
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
14k
Context Engineering - Making Every Token Count
addyosmani
3
60
Unsuck your backbone
ammeep
671
58k
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.9k
Making the Leap to Tech Lead
cromwellryan
135
9.5k
Git: the NoSQL Database
bkeepers
PRO
431
66k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
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?