tags:

views:

36

answers:

1

I have a class like this:

class MyObject
  cattr_accessor :value_

  def +(right_)
    self.value_ + right_.value_
  end
end

I want to be able to do something like this:

x = MyObject.new
y = MyObject.new

x.value_ = 1
y.value_ = 2

puts x + y

It's not working though. Not the cattr_accessor as opposed to attr_accessor, not sure if that has anything to do with it.

A: 

My method works with attr_accessor.

Dex