Linked list example
object initializer called from Class#new
Source: show | on GitHub
# File sample/list.rb, line 4 def initialize(item) # @variables are instance variable, no declaration needed @data = item @succ = nil @head = nil end
# File sample/list.rb, line 11 def data @data end
# File sample/list.rb, line 15 def succ @succ end
the method invoked by “obj.data = val''
# File sample/list.rb, line 20 def succ=(new) @succ = new end