I want to test whether a equals 1 or 2
a
I could do
a == 1 || a == 2
but this requires repeating
First put this somewhere:
class Either < Array def ==(other) self.include? other end end def either(*these) Either[*these] end
Then, then:
if (either 1, 2) == a puts "(i'm just having fun)" end