Fix inconsistent comments Ruby - chapter array and linked list (#1202)

* fix: inconsistent comments Ruby - chapter array and linked list

* fix: better Ruby code & comments
This commit is contained in:
khoaxuantu
2024-03-31 14:58:35 +07:00
committed by GitHub
parent 57bdfd6284
commit 5ce088de52
3 changed files with 15 additions and 15 deletions
@@ -178,8 +178,8 @@
attr_accessor :val # 节点值
attr_accessor :next # 指向下一节点的引用
def initialize(val=nil, next_node=nil)
@val = val || 0
def initialize(val=0, next_node=nil)
@val = val
@next = next_node
end
end
@@ -709,8 +709,8 @@
attr_accessor :next # 指向后继节点的引用
attr_accessor :prev # 指向前驱节点的引用
def initialize(val=nil, next_node=nil, prev_node=nil)
@val = val || 0
def initialize(val=0, next_node=nil, prev_node=nil)
@val = val
@next = next_node
@prev = prev_node
end