i’m so new to Ruby
we can say that attr_accessor :bark
is sugar coating for
def bark
@bark
end
def bark=(val)
@bark = val
end
What would be the same when given multiple parameters
is it?
attr_accessor *args
args.each { |attr|
def attr
@attr
end
def attr=(val)
@attr= val
end
}
and if so how can i use the same with initialization of all given params also
and in class_eval(Meta OOP) with dynamic attr+random_str?
The stuff
won’t work. It would create a method “attr” which returns the value of the instance variable “@attr”. I think that’s not what you want to do, right? You should do
for the getter and almost the same stuff for the setter.
I don’t know what you mean with
regards