On Tue, 25 Oct 2005, Louis J Scoras wrote: >> meth 'hello ', 'world', 'useless', :meat => 'steak', :side => 'potatoes' >> >> harp:~ > ruby a.rb >> Good, I got to say hello world. >> You thought of my third request was useless >> For dinner we have steak >> With a side of potatoes >> >> >> note. it's impossible to determine, if an argument is optional (your >> 'request' >> above) if the last hash passed __is__ that optional argument itself or if >> it's >> the set of keywords. therfore you must pass 'useless' for the request in >> this >> case - if you think about it the parsing is otheriwse impossible. >> >> > Couldn't you require an explicit hash then, if it is intended to be slurped > into the optional parameter? You need to magically realize that this is a > hash in the first place. > > meth 'hello ', 'world', :meat => 'steak', :side => 'potatoes' > > response = 'useless' > meat = 'steak' > side = 'potatoes' > > Would be distinguished from this: > > meth 'hello ', 'world', {:meat => 'steak', :side => 'potatoes'} > > response = {:meat => 'steak', :side => 'potatoes'} > > And this: > > meth 'hello ', 'world', {:meat => 'steak'}, :side => 'potatoes' > > response = {:meat => 'steak'}, > side = 'potatoes' harp:~ > cat a.rb def meth *a, &b p a end meth 'hello', 'world', :meat => 'steak', :side => 'potatoes' meth 'hello', 'world', {:meat => 'steak', :side => 'potatoes'} harp:~ > ruby a.rb ["hello", "world", {:meat=>"steak", :side=>"potatoes"}] ["hello", "world", {:meat=>"steak", :side=>"potatoes"}] these cannot be distinguished. -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | anything that contradicts experience and logic should be abandoned. | -- h.h. the 14th dalai lama ===============================================================================