From: Dave Thomas Date: 2001-08-23T06:19:02+09:00 Subject: [ruby-talk:20123] Re: Maximum Surprise Bob Gustafson writes: > However, I was surprised to find out that the construction > > lots = Hash.new > lots['ALA'] = 2 > lots['IBM'] = 4 > > lots.keys do |k| > puts k > end > > does not print out anything, nor does it flag a syntax violation. This > was a "Maximum Surprise". You can associate a block with any method in Ruby, and there's no real way of knowing whether or not you;re invoking a method that does take a block. In this case, you were passing a block to 'keys' and keys just quietly ignored the fact. It really isn't a syntax issue. However, it might be possible to generate a warning at runtime if you pass a block to a method that doesn't use it (either with an & parameter or by calling yield). Matz? Regards Dave