From: Stephan Mueller Date: 2005-08-07T04:41:08+09:00 Subject: Re: polymorphism and/or named parameters: the ruby way? Hi James, * James Edward Gray II [050806 20:06]: > We can ask for a variable number of arguments, then check for the > various options. Something like: > > def initialize( *args ) > if args.empty? > puts "no param" > elsif args.size == 1 and args.first.is_a? Integer > puts "do it like Beckham" > elsif args.size == 1 and args.first.is_a? String > puts "do it like Ronaldo" > else > raise ArgumentError, "Invalid initialization for # {self.class}." > end > end > > Hope that helps. Yes, thanks a lot. Though i think i like the approach using a hash mentioned in another post a little bit more because it can do the same as this one plus some sort of named params. It depends on the precise situation I guess. Cheers, Steph.