It works!
def keys
keys = [] of String
_keys = uninitialized (Array(String), Node?) ->
_keys = ->(arr : Array(String), node : Node?) do
return 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
Although, i have to use return if node.nil?
instead next if node.nil?
(in ruby), return
return to the _keys.call(...)
, not the method keys
, this is expected, right?
Then, how to return to the keys
method?