From: Rick DeNatale Date: 2007-05-06T08:19:21+09:00 Subject: Re: Noob Concatenation Q? On 5/4/07, Marcin Miel�y�ski wrote:> jervis@o2.ie wrote:> > Can someone briefly explain why ::> > puts i.to_s +" :: "+arrayoutput[i]> >> > yaml.rb:12: undefined method `+@' for " :: ":String (NoMethodError)> > from F:/RUBY/Source/yaml.rb:11:in `times'> > from F:/RUBY/Source/yaml.rb:11> >>> because parens in Ruby are optional, so it ends up:>> puts i.to_s(+" :: "+arrayoutput[i]) Correct and then the + in +"::" is being interpreted by the parser as a unary + which it implements bysending the message :+@ to the string "::". $ qri +@------------------------------------------------------------- Numeric#+@ +num => num------------------------------------------------------------------------ Unary Plus---Returns the receiver's value. -- Rick DeNatale My blog on Rubyhttp://talklikeaduck.denhaven2.com/