hello-algo/codes/ruby/utils/print_util.rb
khoaxuantu 85ca4cce43
feat: Add ruby code - chapter "array & linked list" (#1158)
* feat: add ruby code chapter array & linked list

- array.rb
- linked_list.rb
- list.rb
- my_list.rb

* feat: add ruby code blocks

* chore: fix convention
2024-03-30 13:10:46 +08:00

15 lines
269 B
Ruby

=begin
File: print_util.rb
Created Time: 2024-03-18
Author: Xuan Khoa Tu Nguyen (ngxktuzkai2000@gmail.com)
=end
### 打印链表 ###
def print_linked_list(head)
list = []
while head
list << head.val
head = head.next
end
puts "#{list.join(" -> ")}"
end