RosettaCodeData/Task/Singly-linked-list-Traversal/Ruby/singly-linked-list-traversal.rb
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

13 lines
238 B
Ruby

head = ListNode.new("a", ListNode.new("b", ListNode.new("c")))
head.insertAfter("b", "b+")
# then:
head.each {|node| print node.value, ","}
puts
# or
current = head
begin
print current.value, ","
end while current = current.succ
puts