From: Dirk Detering Date: 2002-06-14T17:44:11+09:00 Subject: Re: procs and blocks Regarding trailing colon as Hash syntax sugar in general: Not only for optical reasons, but the colon notation (which is used for hashes (dictionaries) in python too) is much better to type than the => . On englisch kb layouts you have to type one key in the most upper row and one in the lowest row with shift, both in one hand. On german kb though you can type both with the shift key pressed, you find one char in the upper right corner, the other in the lower left. However, it is annoying if you try to initialize a hash with some more values. Regarding named parameters: Jean-Hugues ROBERT wrote: > BTW: I proposed a syntax sugar for hashes: > a( x, y, foo: "hello", bar: "world") [...] > On the callee side, one could enjoy: > def a( x, y, foo:, bar: "Hello") # foo defaults to nil, > bar to "Hello" Looks both very good to me! Regarding current ways to extract optional parameters: > Apparently foo = (opt && opt.include? :foo) ? opt[:foo] : > is eqv to: foo = opt.fetch( :foo) {} Is it? In the 'Apparently'-line you checked for existence of opt first, but you omitted that in the second version (?). AFAIU the parameter should not be initialized to nil, like you suggested before ... >> a() needs to be something like: >> def a( x, y, opt = nil ) >> foo = (opt && opt.include? :foo) ? opt[:foo] : [...] ... but to an empty hash, as you expect a hash to be given by the user of your method: def a( x, y, opt = {} ) Shouldn't it? Bye Dirk Detering - aka Det