E
EdUarDo
Hi again,
I have this class:
class A
attr_reader :name, :cars
attr_writer :name
def initialize(name)
@name = name
@cars = Array.new()
end
end
a = A.new("xxxx")
a.cars << "vectra" << "megane"
puts a
output:
vectra
megane
Why can I access cars and modify it if I have not declared it how
attr_writer. Must I simply declare it private?
I have this class:
class A
attr_reader :name, :cars
attr_writer :name
def initialize(name)
@name = name
@cars = Array.new()
end
end
a = A.new("xxxx")
a.cars << "vectra" << "megane"
puts a
output:
vectra
megane
Why can I access cars and modify it if I have not declared it how
attr_writer. Must I simply declare it private?