summaryrefslogtreecommitdiff
path: root/ruby/cmp.rb
blob: 65e5c5f86077106615bb9f81118aba4ce94a22c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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