You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! print_tree accept a lambda. The default one emit a puts. but you can pass your code.
for example:
defwork_on_row(node,prefix)# same as default result but on @io@io.puts"#{prefix}#{node.name}"end@io=StringIO.newtree.print_tree(,,method(:work_on_row))#do someting with @io.
The default is for
print_tree
to send output to stdout, I would like the option to send it somewhere else by passing in and IO object to it.Currently, I'm using this workaround, but I don't really like capturing all of stdout (even if temporarily):
I would much rather do something like this:
Or maybe even better, have a method that does the same thing, but returns a string, instead sending to an IO.
The text was updated successfully, but these errors were encountered: