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
62
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Equality in Ruby
Romain Sempé
August 14, 2012
More Decks by Romain Sempé
See All by Romain Sempé
Are you happy with your code quality?
rsempe
0
89
Scan security of your Rails app with Brakeman
rsempe
2
190
Other Decks in Programming
See All in Programming
20260623_Loop Engineeringで自分の分身の問い合わせBotを作る
ryugen04
0
230
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
2
880
【やさしく解説 設計編 #0】DDDのコード、読めるのに分からない人へ
panda728
PRO
2
270
AIエージェントで 変わるAndroid開発環境
takahirom
2
680
AI時代の仕事技芸論〜ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ(スクフェス仙台 2026バージョン)
kuranuki
0
670
ローカルLLMでどこまでコードが書けるか -縮小版 / How much code can be written on a local LLM Shortened
kishida
2
190
関数型プログラミングのメリットって何だろう?
wanko_it
0
180
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
360k
エンジニアにデザインハーネスを 〜デザインプロセスを規定するためのハーネス〜 / Design harness from an engineer's perspective
rkaga
2
1.6k
フィードバックで育てるAI開発
kotaminato
1
120
AI時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
110
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
330
Featured
See All Featured
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
280
The browser strikes back
jonoalderson
0
1.4k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
260
Navigating Team Friction
lara
192
16k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
210
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
180
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?