You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classDogWalkerattr_reader:dogsdefinitialize(*dogs)@dogs=dogsenddefadd_dog(dog)self.dogs=dogs + [dog]endprivateattr_writer:dogsendwalker=DogWalker.new("milo","lola")walker.add_dog("Bean")# (uses the private attr_writer)walker.dogs=[1,2,3]# (tries to use the attr_writer but fails because it's private)
The attr_writer :dogs there is private, but this generates a Lint/UselessAccessModifier offense even though sometimes it is useful to define a private setter (not sure how useful this particular example is 😄)
The text was updated successfully, but these errors were encountered:
Consider this code:
The
attr_writer :dogs
there is private, but this generates aLint/UselessAccessModifier
offense even though sometimes it is useful to define a private setter (not sure how useful this particular example is 😄)The text was updated successfully, but these errors were encountered: