From: Robert Feldt Date: 2000-09-22T19:10:02+09:00 Subject: [ruby-talk:5063] Default values for named formal parameters Hi, We have some sort of named formal parameters, ie you can do def m(params) params['p1'] + params['2'] end m('p1' => "Hello ", 'p2' => "world!") # -> "Hello world!" but is there a nice way to have default values for the named parameters? Ie. I would like def m(params = {'p1'=>"Hello ", 'p2'=>" world!"}) params['p1'] + params['p2'] end m('p2' => "Matz!") # -> "Hello Matz!" One way you can do it today is with def m(params) params = {'p1'=>"Hello",'p2'=>" world!"}.update(params) params['p1'] + params['p2'] end but if they should really be named formal parameters I guess you should be able to specify default values with a simpler syntax. Or what do you think? How do you do it yourself when you classes with lots of options? I made a small module for this once but I'm thinking on extending it... Regards, Robert