Ruby OOP

When attr_accessor :name is available inside a class, if instance varaible is not assign yet, we should use self.name = “something” to assign it.

If you use name = “something” to try to invoke setter method before a instance variable create, Ruby will assume that you are going to create a local variable.

Show your support

Clapping shows how much you appreciated newfishg’s story.