E
eastcoastcoder
Very often, I'd like to ensure (and document) that a method will not
change any of its parameters:
# This looks at, but doesn't modify, a and b
def mymethod(a, b)
end
In C++ I can do this with the const modifier.
Is there anyway to do this in Ruby?
I'd call freeze, except that would freeze the original a as well.
I'd call dup/clone and then freeze, but those aren't deep copies, from
what I understand.
So, I guess my question boils down to:
Is there a way to make a frozen, full (ie deep) copy of an object?
change any of its parameters:
# This looks at, but doesn't modify, a and b
def mymethod(a, b)
end
In C++ I can do this with the const modifier.
Is there anyway to do this in Ruby?
I'd call freeze, except that would freeze the original a as well.
I'd call dup/clone and then freeze, but those aren't deep copies, from
what I understand.
So, I guess my question boils down to:
Is there a way to make a frozen, full (ie deep) copy of an object?