Joel VanderWerf
8/26/2008 10:49:00 PM
Kless wrote:
> if I define a function with several args. as
> ----------
> def func(foo, bar)
> ----------
> and is used with the changed args.:
> ----------
> func(bar='wrong', foo='order')*
> ----------
> it will change the order of args. and this is not desirable, how to
> solve it?
>
> I imagine this with a lot of args. and could be danger
Use a hash argument
def func(args={})
bar=args[:bar]
foo=args[:foo]
end
func(:bar=>1, :foo=>2)
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407