S
Simon Strandgaard
It just hit me.. why not let kind_of? take more arguments?
irb(main):001:0> x = 3
=> 3
irb(main):002:0> x.kind_of?(String)
=> false
irb(main):003:0> x.kind_of?(String, Fixnum)
ArgumentError: wrong number of arguments(2 for 1)
from (irb):3:in `kind_of?'
from (irb):3
irb(main):004:0>
For instance I have
def push(choice)
if choice.kind_of?(Zero) == false and choice.kind_of?(One) == false
raise "got #{choice.class}"
end
@choices << choice
end
It could turn into
def push(choice)
unless choice.kind_of?(Zero, One)
raise "got #{choice.class}"
end
@choices << choice
end
irb(main):001:0> x = 3
=> 3
irb(main):002:0> x.kind_of?(String)
=> false
irb(main):003:0> x.kind_of?(String, Fixnum)
ArgumentError: wrong number of arguments(2 for 1)
from (irb):3:in `kind_of?'
from (irb):3
irb(main):004:0>
For instance I have
def push(choice)
if choice.kind_of?(Zero) == false and choice.kind_of?(One) == false
raise "got #{choice.class}"
end
@choices << choice
end
It could turn into
def push(choice)
unless choice.kind_of?(Zero, One)
raise "got #{choice.class}"
end
@choices << choice
end