Soumettre la recherche
Mettre en ligne
All Objects are created .equal?
•
0 j'aime
•
539 vues
G
gsterndale
Suivre
Understanding equality in your Ruby codez https://github.com/gsterndale/equality
Lire moins
Lire la suite
Technologie
Divertissement et humour
Signaler
Partager
Signaler
Partager
1 sur 30
Télécharger maintenant
Télécharger pour lire hors ligne
Recommandé
ScotRuby - Dark side of ruby
ScotRuby - Dark side of ruby
Gautam Rege
Licão 10 operators
Licão 10 operators
Acácio Oliveira
F# intro
F# intro
Alexey Raga
Refactor like a boss
Refactor like a boss
gsterndale
Web 2.0 - Beta
Web 2.0 - Beta
vaclav.lohr
Performance Architecture Manifesto
Performance Architecture Manifesto
sirlegendary
SIR Brochure
SIR Brochure
sirlegendary
School Presentation St Peter's RC Primary School and Nursery
School Presentation St Peter's RC Primary School and Nursery
Tiina Sarisalmi
Recommandé
ScotRuby - Dark side of ruby
ScotRuby - Dark side of ruby
Gautam Rege
Licão 10 operators
Licão 10 operators
Acácio Oliveira
F# intro
F# intro
Alexey Raga
Refactor like a boss
Refactor like a boss
gsterndale
Web 2.0 - Beta
Web 2.0 - Beta
vaclav.lohr
Performance Architecture Manifesto
Performance Architecture Manifesto
sirlegendary
SIR Brochure
SIR Brochure
sirlegendary
School Presentation St Peter's RC Primary School and Nursery
School Presentation St Peter's RC Primary School and Nursery
Tiina Sarisalmi
What WELD does
What WELD does
Reid Williams
plaY [commercial]
plaY [commercial]
smwarfield
Personagraph Whitepaper
Personagraph Whitepaper
Tapan Kamdar
Digital Trends Impacting News Companies
Digital Trends Impacting News Companies
Reid Williams
Server Side 2009
Server Side 2009
vaclav.lohr
Copyright and Fair Use for USU Extension
Copyright and Fair Use for USU Extension
Britt Fagerheim
Third comeback report 4.8,2011
Third comeback report 4.8,2011
Carlos Miranda Levy
Ctm louvre
Ctm louvre
claireso
The vmware story
The vmware story
Gian Marco Pizzuti
Change history with Git
Change history with Git
gsterndale
Czech Day in Kozani
Czech Day in Kozani
Tiina Sarisalmi
Como subir una actividad o tarea a moodle
Como subir una actividad o tarea a moodle
Jose Ramirez
Sinsai.info and Crisis Mapping
Sinsai.info and Crisis Mapping
Carlos Miranda Levy
SEO pro manažery
SEO pro manažery
vaclav.lohr
Smartfren Network Test Drive Jakarta - Yogyakarta
Smartfren Network Test Drive Jakarta - Yogyakarta
Jarwadi MJ
Lunch Menus and Recipes from Portugal
Lunch Menus and Recipes from Portugal
Tiina Sarisalmi
Integrating Library Resources into Blackboard
Integrating Library Resources into Blackboard
Britt Fagerheim
Christmas Handicraft by Thanasis
Christmas Handicraft by Thanasis
Tiina Sarisalmi
Kort Om Etikk2
Kort Om Etikk2
guest8e448c
Library As Teaching Resource
Library As Teaching Resource
Britt Fagerheim
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
Hervé Boutemy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc
Contenu connexe
En vedette
What WELD does
What WELD does
Reid Williams
plaY [commercial]
plaY [commercial]
smwarfield
Personagraph Whitepaper
Personagraph Whitepaper
Tapan Kamdar
Digital Trends Impacting News Companies
Digital Trends Impacting News Companies
Reid Williams
Server Side 2009
Server Side 2009
vaclav.lohr
Copyright and Fair Use for USU Extension
Copyright and Fair Use for USU Extension
Britt Fagerheim
Third comeback report 4.8,2011
Third comeback report 4.8,2011
Carlos Miranda Levy
Ctm louvre
Ctm louvre
claireso
The vmware story
The vmware story
Gian Marco Pizzuti
Change history with Git
Change history with Git
gsterndale
Czech Day in Kozani
Czech Day in Kozani
Tiina Sarisalmi
Como subir una actividad o tarea a moodle
Como subir una actividad o tarea a moodle
Jose Ramirez
Sinsai.info and Crisis Mapping
Sinsai.info and Crisis Mapping
Carlos Miranda Levy
SEO pro manažery
SEO pro manažery
vaclav.lohr
Smartfren Network Test Drive Jakarta - Yogyakarta
Smartfren Network Test Drive Jakarta - Yogyakarta
Jarwadi MJ
Lunch Menus and Recipes from Portugal
Lunch Menus and Recipes from Portugal
Tiina Sarisalmi
Integrating Library Resources into Blackboard
Integrating Library Resources into Blackboard
Britt Fagerheim
Christmas Handicraft by Thanasis
Christmas Handicraft by Thanasis
Tiina Sarisalmi
Kort Om Etikk2
Kort Om Etikk2
guest8e448c
Library As Teaching Resource
Library As Teaching Resource
Britt Fagerheim
En vedette
(20)
What WELD does
What WELD does
plaY [commercial]
plaY [commercial]
Personagraph Whitepaper
Personagraph Whitepaper
Digital Trends Impacting News Companies
Digital Trends Impacting News Companies
Server Side 2009
Server Side 2009
Copyright and Fair Use for USU Extension
Copyright and Fair Use for USU Extension
Third comeback report 4.8,2011
Third comeback report 4.8,2011
Ctm louvre
Ctm louvre
The vmware story
The vmware story
Change history with Git
Change history with Git
Czech Day in Kozani
Czech Day in Kozani
Como subir una actividad o tarea a moodle
Como subir una actividad o tarea a moodle
Sinsai.info and Crisis Mapping
Sinsai.info and Crisis Mapping
SEO pro manažery
SEO pro manažery
Smartfren Network Test Drive Jakarta - Yogyakarta
Smartfren Network Test Drive Jakarta - Yogyakarta
Lunch Menus and Recipes from Portugal
Lunch Menus and Recipes from Portugal
Integrating Library Resources into Blackboard
Integrating Library Resources into Blackboard
Christmas Handicraft by Thanasis
Christmas Handicraft by Thanasis
Kort Om Etikk2
Kort Om Etikk2
Library As Teaching Resource
Library As Teaching Resource
Dernier
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
Hervé Boutemy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
BookNet Canada
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
Lars Bell
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
RankYa
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
ScyllaDB
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
Curtis Poe
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
BookNet Canada
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
null - The Open Security Community
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
Fwdays
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
charlottematthew16
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
Slibray Presentation
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
Sri Ambati
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
Alex Barbosa Coqueiro
How to write a Business Continuity Plan
How to write a Business Continuity Plan
Databarracks
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Precisely
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
Dilum Bandara
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
Scott Keck-Warren
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
Lorenzo Miniero
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
Pixlogix Infotech
Dernier
(20)
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
How to write a Business Continuity Plan
How to write a Business Continuity Plan
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
All Objects are created .equal?
1.
All Objects Are
Created .equal? Understand equality in your Ruby codez
2.
github.com/gsterndale/equality
3.
Equality methods a ==
b a === b a.eql? b a.equal? b
4.
==
5.
Everyday equality (==) a
== b
6.
Default == a =
MyBasicClass.new b = MyBasicClass.new a == b # => false b = a a == b # => true
7.
Overriding == class RomanNumeral
def ==(other) if other.respond_to?(:to_f) self.to_f == other.to_f else false end end end
8.
Overriding == iv
= RomanNumeral.new('IV') iiii = RomanNumeral.new('IIII') iv == iiii # => true
9.
===
10.
case statement equality
(===) a === b
11.
Default === a =
Object.new b = Object.new case a when b 'b must === a' else 'b must NOT === a' end # => "b must NOT === a"
12.
Float === a =
1 b = 1.0 case a when b 'b must === a' else 'b must NOT === a' end # => "b must === a"
13.
Regexp === case '123' when
/d+/ 'At least one number' else 'No numbers found' end # => "At least one number"
14.
When === !=
== /d+/ == '123' # => false /d+/ === '123' # => true
15.
Class === case 'abc' when
String 'It is a String!' else 'Not a String' end # => "It is a String!"
16.
Asymmetry /d+/ === '123' #
=> true '123' === /d+/ # => false
17.
Asymmetry 2 === Integer #
=> false Integer === 2 # => true Fixnum === 2 # => true
18.
.equal?
19.
Object equality (.equal?) a
= 'FOO' b = a a.equal? b # => true a.equal? 'FOO' # => false
20.
.eql?
21.
Hash key equality
(.eql?) a.eql? b
22.
Default .eql? foo =
Object.new hash = { foo => 'My value' } bar = Object.new foo.equal? bar # => false foo.eql? bar # => false hash[bar] # => nil
23.
String .eql? foo =
'My Key' hash = { foo => 'My value' } bar = 'My Key' foo.equal? bar # => false foo.eql? bar # => true hash[bar] # => "My value"
24.
Overriding .eql? class RomanNumeral
def eql?(other) other.kind_of?(RomanNumeral) && self.to_i.eql?(other.to_i) end end
25.
Overriding .eql? iv
= RomanNumeral.new('IV') hash = { iv => 'Four' } iiii = RomanNumeral.new('IIII') iv.equal? iiii # => false iv.eql? iiii # => true hash[iiii] # => "Four"
26.
Comparable
27.
Comparison methods # You
must define <=> a <=> b # => -1, 0, 1 -or- nil a == b a > b a < b a >= b a <= b c.between?(a, b)
28.
Overriding <=> class RomanNumeral
def <=>(other) if other.respond_to?(:to_f) self.to_f <=> other.to_f else nil end end end
29.
Overriding <=> v =
RomanNumeral.new('V') x = RomanNumeral.new('X') v <=> x # => -1 v >= x # => false RomanNumeral.new('VIII').between?(v, x) # => true
30.
Sorting Enumerables iv
= RomanNumeral.new('IV') iiii = RomanNumeral.new('IIII') x = RomanNumeral.new('X') [iv, x, iiii] # => [IV, X, IIII] [iv, x, iiii].sort # => [IV, IIII, X]
Télécharger maintenant