Skip to content

Instantly share code, notes, and snippets.

@kiyoka
Last active August 29, 2015 14:00
Show Gist options
  • Save kiyoka/11291245 to your computer and use it in GitHub Desktop.
Save kiyoka/11291245 to your computer and use it in GitHub Desktop.
Ruby and Gauche(Scheme)'s equal operators
ruby 2.0.0p353
$ irb
irb(main):001:0> a = "abc"
=> "abc"
irb(main):002:0> b = "abc"
=> "abc"
irb(main):003:0> a == b
=> true
irb(main):004:0> a === b
=> true
irb(main):005:0> a.equal? b
=> false
irb(main):006:0> a = :abc
=> :abc
irb(main):007:0> b = :abc
=> :abc
irb(main):008:0> a == b
=> true
irb(main):009:0> a === b
=> true
irb(main):010:0> a.equal? b
=> true
irb(main):011:0> quit
Gauche scheme shell, version 0.9.3.3
$ gosh
gosh> (define a "abc")
a
gosh> (define b "abc")
b
gosh> (eq? a b)
#f
gosh> (eqv? a b)
#f
gosh> (equal? a b)
#t
gosh> (define a :abc)
a
gosh> (define b :abc)
b
gosh> (eq? a b)
#t
gosh> (eqv? a b)
#t
gosh> (equal? a b)
#t
gosh>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment