From 29f237a8b1df650089b54447f070726c75706b6f Mon Sep 17 00:00:00 2001 From: Yukihiro Matsumoto Date: Fri, 14 Oct 1994 06:19:03 +0900 Subject: version 0.54 https://cache.ruby-lang.org/pub/ruby/1.0/ruby-0.54.tar.gz --- sample/list3.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 sample/list3.rb (limited to 'sample/list3.rb') diff --git a/sample/list3.rb b/sample/list3.rb new file mode 100644 index 0000000000..c38e5bfb43 --- /dev/null +++ b/sample/list3.rb @@ -0,0 +1,20 @@ +# Linked list program -- short version +class Point + def Point.new(x, y) + super.init(x, y) + end + + def init(x, y) + @x = x; @y = y + self + end + + def to_s + sprintf("%d@%d", @x, @y) + end +end + +list1 = [10, 20, Point.new(2, 3), Point.new(4, 5)] +list2 = [20, Point.new(4, 5), list1] +print("list1: ", list1._inspect, "\n") +print("list2: ", list2._inspect, "\n") -- cgit v1.2.3