Here is my ruby code
class Demo
attr_accessor :lines
def initialize(lines)
self.lines = lines
end
end
In the above code I could have
self.lines
is a method, @lines
is the instance variable. In your constructor you'll want to use self.lines I would argue, but that's up for debate. It's just a stylistic difference, really. If you want a deeper discussion of direct vs. indirect variable access, read the chapter from Kent Beck's Smalltalk Best Practice Patterns.