> -----Original Message----- > From: Gavin Sinclair [mailto:gsinclair / soyabean.com.au] > Sent: Wednesday, August 07, 2002 12:00 PM > To: ruby-talk ML > Subject: Re: Named paramters again > > > <SNIP> > > AFAIC, the *point* of allowing (*not* enforcing) named parameters is so > that > the programmer can alter the parameter order. That way, if a method has > several parameters, you don't have to remember the order. This is really > only suited to those situations where a class or method is data-heavy. In > these situations, there is generally nothing special about parameter > order. > Named parameters can also be used to allow for methods where default values are supplied for specific parameters: def foo(x, y=2, z=3) ... end If you want to call this and set 'z' but leave 'y' is default value, named parameters are your friend. foo(2, z: 4) Where this is used a lot in python are constructors in GUI widgets were lots of default values can be set and you only need to provide those you wish to 'override'...and yes...order independence becomes relevant here too because you will have a hard time maintaining the order in your head for 20 or 30 parameters. Granted, you could just implement this as subsequent calls to attribute getter/setters, but it's nice to be able to do it in widget construction. -rich