Sarah Allen wrote: > However, in some cases, spaces seem to matter: In *many* cases spaces matter :-) >> a = -3 => -3 >> puts (a+1).abs 2 => nil >> puts(a+1).abs -2 NoMethodError: undefined method `abs' for nil:NilClass from (irb):3 from :0 If unsure: - put parentheses around method arguments - put spaces around operators > Can someone explain what "undefined method `-@'" refers to? -@ is the unary minus method, +@ is the unary plus method. class Foo def -@ "Minused" end def +@ "Plussed" end end f = Foo.new puts(-f) puts(+f) Aside: as a symbol, the method name is :-@. This lets you write smiley programs: puts f.send(:-@) As well as most operators, there are some other syntactic constructs which map to method calls. e.g. class Foo def [](*args) "Index" end end puts f[] puts f.send(:[]) -- Posted via http://www.ruby-forum.com/.