method
[]=

[]=( index, element )
public
Sets an element, replacing any previous matching element. If no existing element is found ,the element is added.
Used to find a matching element to replace. See [](). | |
element |
The element to replace the existing element with the previous element |
Returns |
nil if no previous element was found. |
doc = Document.new ‘<a/>’ doc.root.elements[10] = Element.new(‘b’) #-> <a> doc.root.elements[1] #-> <b/> doc.root.elements[1] = Element.new(‘c’) #-> <a><c/> doc.root.elements[‘c’] = Element.new(‘d’) #-> <a><d/>