2

I have a nodeset in the variable my_nodeset

I'd like to remove the last node that was found.

Initially i expected this to work: my_nodeset.last.remove but it does not.

The only way I've found to remove the last item is with something like this: my_nodeset.delete(my_nodeset.last)

Seems strange to me and i was wondering if there's a "correct" way to do it. Thanks!

Mario Zigliotto
  • 8,315
  • 7
  • 52
  • 71

1 Answers1

3

It is not strange to me.

my_nodeset.last.remove means:

call Nodeset my_nodeset then go to its last Node member and call remove method (owned by last). You want to ask to a Node method to modify a NodeSet. That's semantically wrong to me.

my_nodeset.delete(my_nodeset.last) is how it should be.

dierre
  • 7,140
  • 12
  • 75
  • 120