From: Love U Ruby Date: 2013-03-11T21:31:29+09:00 Subject: Re: Confusion with block local variable declaration with block variable declaration within the pipe Okay! Thanks for your help! >> a="" => "" >> a << " ".capitalize! TypeError: can't convert nil into String from (irb):2 from C:/Ruby193/bin/irb:12:in `
' Got the above one. Well. `a = "hello world".split(//).each{ |x| newstr << x.capitalize }` is running on your IRB. I think it should not. >> a = "hello world".split(//).each{ |x| newstr << x.capitalize } NameError: undefined local variable or method `newstr' for main:Object from (irb):3:in `block in irb_binding' from (irb):3:in `each' from (irb):3 from C:/Ruby193/bin/irb:12:in `
' The error is so obvious. But don't know why author choose this code to explain.:( -- Posted via http://www.ruby-forum.com/.