3 # object initializer called from Class#new
5 # @variables are instance variable, no declaration needed
18 # the method invoked by ``obj.data = val''
43 # the method to convert object into string.
44 # redefining this will affect print.
48 # short form of ``str = str + elt.data.to_s + "\n"''
49 str += elt.data.to_s + "\n"
63 sprintf("%d@%d", @x, @y)
67 # global variable name starts with `$'.
69 $list1.add_to_list(10)
70 $list1.add_to_list(20)
71 $list1.add_to_list(Point.new(2, 3))
72 $list1.add_to_list(Point.new(4, 5))
74 $list2.add_to_list(20)
75 $list2.add_to_list(Point.new(4, 5))
76 $list2.add_to_list($list1)
78 # parenthesises around method arguments can be ommitted unless ambiguous.
79 print "list1:\n", $list1, "\n"
80 print "list2:\n", $list2, "\n"