Is there any way to protect an instance variable from being written to/modified in Ruby?
Say I do this:
class Test
def initialize(var)
@var = var
end
def modify
@var = "test" # This would raise an error, saying '@var' is just readable.
end
end
Is there any way to make instance variable to be read-only? If not, which kind of attribute am I looking for?