Documentation says this about node name: "Expected to be unique within the tree". But what could happend when names are not unique? In many cases you really don't need to care about it, you don't need a unique id.
I'd like you make a comment about it in documentation.
Thank you for your project! And congraturatons! You got rubytree is the facto ruby standart for a very very important data structure.
The text was updated successfully, but these errors were encountered:
The issue with the node name having to be unique is that the internal data structures are based on hashes, and also the semantic does require that each of the nodes in the tree be directly accesible via the node name (we could potentially change the logic so that an array of nodes is returned if the name is the same, but this might not be exactly what we need).
I think a better option would be to treat the name as a unique handler/ID for the node, and the duplicate node objects themselves can be added in the value part. This actually works out better (and works in the current version as well).
I am going to take your suggestion to update the documentation so that this scenario is addressed more explicitly.
Thank you for answering. I could use object_id as node id, it's easy, it's unique. So I could forget that unique id issue, that I don't really care for my purposes. I'd use value for node tag and other node data.
Thank you again.