I have a custom class and want to be able to override the assignment operator. Here is an example:
class MyArray < Array
attr_accessor :direction
def
The problem is
def strategy=(strategy, direction = :forward)
@strategy = strategy
@strategy.direction = direction
end
When you set
h.strategy = :mystrategy, :backward
you are actually overriding the original @strategy
instance. After that call, @strategy
is an instance of Symbol
, not MyArray
.
What do you want to do? Replace the object or update it?