Following code not work on crystal.
def keys
keys = [] of String
_keys = proc do |arr, node|
next if node.nil?
_keys.call(arr, node.left)
arr << node.key unless node.key == ''
_keys.call(arr, node.right)
end
_keys.call(keys, @root)
keys
end
80 | _keys.call(arr, node.left)
^
Error: can't use variable name '_keys' inside assignment to variable '_keys'
Bascially, it just equal to:
def keys
keys = [] of String
_keys(keys, root)
keys
end
def _keys(arr, node)
return if node.nil?
_keys(arr, node.left)
arr << node.key unless node.key.blank?
_keys(arr, node.right)
end
How to fix that?
Thank you.