1 # Linked list example -- short version
2 class Point
3 def initialize(x, y)
4 @x = x; @y = y
5 self
6 end
7
8 def to_s
9 sprintf("%d@%d", @x, @y)
10 end
11 end
12
13 list1 = [10, 20, Point.new(2, 3), Point.new(4, 5)]
14 list2 = [20, Point.new(4, 5), list1]
15 print("list1:\n", list1.join("\n"), "\n")
16 print("list2:\n", list2.join("\n"), "\n")