Hi Robert, On Tue, 1 Feb 2005 03:30:46 +0900, Robert Klemme <bob.news / gmx.net> wrote: > > "Matt Mower" <matt.mower / gmail.com > schrieb im Newsbeitrag > news:d563731905013109382bbeef75 / mail.gmail.com... > > Hi. > > > > I want to dynamically create (i'm trying to use define_method) a > > method using which has default values for it's parameters. However > > when I try to do: > > > > define_method "name" lambda { |x=1,y=2,z=3| f(x,y,z) } > > > > I get a syntax error on the x=1 part. Am I just using the wrong > > syntax? Or is it really not possible to create methods with default > > parameter values dynamically? > > I guess you will have to do > > define_method( "name" ) { |*a| f(a[0]||1, a[1]||2, a[2]||3) } > > Or something similar. > Ah, thank you -- I had thought of using || to get the defaults but not to use |*a| to allow parameters to be passed, or not, which is the vital bit. Since this workaround is a touch unaesthetic I wonder whether there was a particular reason for not allowing default values to be specified for block parameters? Do you happen to know? Thanks again. M -- Matt Mower :: http://matt.blogs.it/