[libxml-devel] << operator
Charlie Savage
cfis at savagexi.com
Wed Aug 20 23:58:43 EDT 2008
This code:
node = XML::Node.new('foo') << XML::Node.new('bar') << "bars contents"
Generates this xml:
puts node
<foo><bar/>bars contents</foo>
That is because the << returns self.
Eric Musgrove if instead it should work like this (see
http://rubyforge.org/tracker/?func=detail&atid=1971&aid=21424&group_id=494):
puts node.parent.parent
<foo>
<bar>bars contents</bar>
<foo>
By making the << operator return the appended node.
<< returning the appended node seems more useful, but doesn't follow the
Ruby standard as pointed out by Masashi Shimbo.
Thoughts?
Charlie
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://rubyforge.org/pipermail/libxml-devel/attachments/20080820/2cb4778b/attachment.bin>
More information about the libxml-devel
mailing list