evolve75/RubyTree

TreeNode with integer names

aidansteele opened this issue · 3 comments

Tree::TreeNode#[] has an optional second parameter that can be provided to indicate that the "name" of a node is an integer. However, when a node is initialised with an integer as a name, a warning is raised in all cases.

Ideally, I'd like for no warnings to be printed to stdout when my program is running, but right now there isn't a parameter for Tree::TreeNode#initialize to indicate that an integer name is intentional and that I don't need to be warned.

Is there interest in providing such an option?

I might have spoken too soon. Looking into the structed_warnings gem, it is possible to selectively disable warnings. I could do:

StandardWarning.disable do
  node = Tree::TreeNode.new 1234
end

I'll have to check if there's any significant runtime overhead to this approach. :)

Turns out it's a fair bit quicker, presumably because it doesn't need to flush all that data to stdout! I'm happy with this outcome so I will close this issue as resolved and stop spamming. :)

@aidansteele,

Thanks for resolving this! In any case, I will add the solution to the API documentation.