#kind_of? take multiple arguments.
def push(choice)
unless choice.kind_of?(Zero) or choice.kind_of?(One)
raise ArgumentError, "got #{choice.class}"
end
@choices << choice
end
def push(choice)
unless choice.kind_of?(Zero, One)
raise ArgumentError, "got #{choice.class}"
end
@choices << choice
end
instance_of?.
class Object
alias old_kind_of kind_of?
def kind_of?( *classes )
classes.each{|cl| return true if old_kind_of(cl) }
false
end
end
p 3.kind_of?(String) # false
p 3.kind_of?(String, Fixnum) # true
Back to RCRchive.
RCR Submission page and RCRchive powered by Ruby, Apache, RuWiki (modified), and RubLog