From: Robert Klemme Date: 2011-08-26T23:36:29+09:00 Subject: Re: overloading methods question please? On Fri, Aug 26, 2011 at 3:51 PM, Alexey Muranov wrote: > Yes, Hans Mackowiak is right, the case operator is more complicated than > i thought. > How would you case a class in this case? > > klass = a.class > >  case klass >  when ??? >  ... A generic solution is def do_something(*args) case args.map(&:class) when [String, String] puts "Working on two Strings" when [Integer, String], [Fixnum, String], [Bignum, String] puts "Working on int and String" else raise TypeError, "Dunno what to do with %p" % [args] end end As you can see this soon becomes unwieldy. Which brings us back to > > it must be > > ... never done. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/