diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-01-16 12:13:05 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-01-16 12:13:05 +0000 |
| commit | 99d0354e89aefdb6373dbeb22506216b8790a0bd (patch) | |
| tree | b3c086e437cab449f90ba637710daed0ddfec4c4 /sample/list3.rb | |
| parent | 502e7547b5c274c51365d11fdfe0e69ee9aa5a52 (diff) | |
| download | ruby-99d0354e89aefdb6373dbeb22506216b8790a0bd.tar.gz ruby-99d0354e89aefdb6373dbeb22506216b8790a0bd.tar.xz ruby-99d0354e89aefdb6373dbeb22506216b8790a0bd.zip | |
Initial revision
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@2 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample/list3.rb')
| -rw-r--r-- | sample/list3.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sample/list3.rb b/sample/list3.rb new file mode 100644 index 000000000..1d756fdff --- /dev/null +++ b/sample/list3.rb @@ -0,0 +1,18 @@ +# Linked list example -- short version +# using inspect + +class Point + def initialize(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") |
