From: james@... Date: 2002-03-27T00:06:08+09:00 Subject: RE: yield in iterator's body - > > Can we write in Ruby something like this : > > a1.each { |f| ... yield f } { |g| ... yield g } ... > This ... ["H", "A", "L"].collect { |x| x.succ }.each{|b| puts "I got #{b}" } ... produces I got I I got B I got M However, this ... ["H", "A", "L"].each { |x| x.succ }.each{|b| puts "I got #{b}" } .. gives: I got H I got A I got L So, my question is, what exactly is the difference between 'each' and 'collect'? Why doesn't the 'each' block return the value of the last expression? James