Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

equality == is based on index only #2

Closed
atomgas opened this Issue · 3 comments

2 participants

@atomgas

I think something like this is missing

module Renum
  class EnumeratedValue
    def ==(other)
      self.class == other.class && self.<=>(other).zero?
    end
  end
end
@duelinmarkers
@atomgas
irb(main):002:0> enum :Status, [ :NOT_STARTED, :IN_PROGRESS, :COMPLETE ]
=> [Status::NOT_STARTED, Status::IN_PROGRESS, Status::COMPLETE]
irb(main):003:0> enum :Color, [ :RED, :GREEN, :BLUE ]
=> [Color::RED, Color::GREEN, Color::BLUE]
irb(main):004:0> Status::NOT_STARTED == Color::RED
=> true
irb(main):005:0>
@duelinmarkers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.