[libxml-devel] << operator
Charlie Savage
cfis at savagexi.com
Thu Aug 21 15:29:22 EDT 2008
> node = XML::Node.new('foo') << XML::Node.new('bar') << "bars contents"
>
> puts node.parent.parent
>
> <foo>
> <bar>bars contents</bar>
> <foo>
FYI - one downside of returning the appended object as opposed to self
is that the variable node above is the "bar contents" node. Thus you
have to write:
puts node.parent.parent.
I find that surprising. It would be nice if node was the top node.
Thus in the example it would be nice for << to return the child object
in some cases and self in others. Sigh.
Anyone see a way of getting the best of both worlds?
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/20080821/f7073142/attachment-0001.bin>
More information about the libxml-devel
mailing list