From: Paul Sutton Date: 2012-06-14T06:26:29+09:00 Subject: Re: Calling methods, getting string and adding them On Thu, 2012-06-14 at 05:54 +0900, Sam Duncan wrote: > On 14/06/12 08:48, Michael Sung wrote: > > I was wondering why this is not being accepted? I get an error stating > > that + is an unknown method. > > > > I defined a Class and 3 methods within the class, and am merely calling > > the methods and trying to add them together for display from one line: > > > > > > m.ClassMethodString + " " + m.ClassMethodString + ": " + > > m.ClassMethodInteger.to_s > > > Please post your class, or even better the entire code =] And the actual error... most likely your function isn't returning a string. The error should tell you want class '+' is not defined in. For example, if your method returns nil you'll get: NoMethodError: undefined method `+' for nil:NilClass Easiest fix would be to call to_s on the return value of your methods (e.g. m.ClassMethodString.to_s) but that might merely cover-up some problem with your method's return value. -Paul