私はルビーの初心者です。ルビの変数の問題
私の問題は、値と参照による引数渡しです。
私は、配列の内容は、親ノードであるが、この方法
def show_as_tree(parents)
array = []
iterate_categories(parents, array)
end
def iterate_categories(parents, array)
parents.each do |p|
#return p.description or "-#{p.description} if the node is root or not
p.description = category_name(p)
#add to array
array << p
#call iterate categories with children of parent node and same array
iterate_categories(p.children, array)
end
end
をコーディングしています。
参考のためにルビーの仕組みを理解する必要がありますが、どうすれば問題を解決できますか?
どのオブジェクトでもobject_idメソッドを使用して質問に対する回答を得ることができます。 – taro