From: Arup Rakshit Date: 2013-02-03T07:12:44+09:00 Subject: Re: Why none of the block giving the expected output with the "enumerator"? unknown wrote in post #1094928: > Am 02.02.2013 21:20, schrieb Arup Rakshit: > What you probably misinterpreted as the output (the part after '=>') > is actually the value of the evaluated expresssion, which in this case > is the return value of the each method (-> the array itself, see docs). > Besides the output generated by puts statements etc., irb always > additionally outputs the value of the evaluated expression. > >> irb(main):021:0> a.each{|x,y| x-y } >> TypeError: nil can't be coerced into Fixnum >> from (irb):21:in `-' >> from (irb):21:in `block in irb_binding' >> from (irb):21:in `each' >> from (irb):21:in `each' >> from (irb):21 >> from C:/Ruby193/bin/irb:12:in `
' > > This cannot work, because #each yields exactly one parameter (see docs). > y therefore always is nil and nil cannot be subtracted from x. `+1` to you. You guided me perfectly! :) -- Posted via http://www.ruby-forum.com/.