D
Daniel Schierbeck
Yes, it's time for another Symbol trick!
class Symbol
def ===(obj)
obj.respond_to? "to_#{self}"
end
end
case "foo"
when :int then "integer"
when :str then "string"
when :ary then "array"
end #=> "string"
Genius. Sheer genius.
Daniel
class Symbol
def ===(obj)
obj.respond_to? "to_#{self}"
end
end
case "foo"
when :int then "integer"
when :str then "string"
when :ary then "array"
end #=> "string"
Genius. Sheer genius.
Daniel