+ 6
In Ruby what's the difference between doing @name or self.name ?
class Person attr_accessor :name, :age def initialize(name, age) @name = name @age = age end def change(n, a) self.name = n @age = a end end p = Person.new("David", 28) p.change("Bob", 42) puts p.name puts p.age #Output Bob 42
1 Réponse