method
[]=
[]=( index, element )
public
Sets an element, replacing any previous matching element. If no existing element is found ,the element is added.
index: | 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><b/></a> doc.root.elements[1] #-> <b/> doc.root.elements[1] = Element.new('c') #-> <a><c/></a> doc.root.elements['c'] = Element.new('d') #-> <a><d/></a>