diff options
author | Patrick Simianer <p@simianer.de> | 2014-06-14 16:46:27 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-06-14 16:46:27 +0200 |
commit | 26c490f404731d053a6205719b6246502c07b449 (patch) | |
tree | 3aa721098f1251dfbf2249ecd2736434c13b1d48 /ruby/cmp.rb |
init
Diffstat (limited to 'ruby/cmp.rb')
-rwxr-xr-x | ruby/cmp.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/ruby/cmp.rb b/ruby/cmp.rb new file mode 100755 index 0000000..65e5c5f --- /dev/null +++ b/ruby/cmp.rb @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby + + +class A + attr_accessor :a + + def initialize a + @a = a + end + + def == other + @a.size == other.a.size + end + alias :eql? :== + + def hash + @a.hash + end +end + +a = A.new 'a' +b = A.new 'b' +ax = A.new 'a' + +puts a == ax + +l = [a, b, ax] +puts l.uniq.size + |