From: Sean Russell Date: 2001-11-14T08:52:03+09:00 Subject: [ruby-talk:25107] Re: REXML behavior change RFC Sean Chittenden wrote: > Why not overload to_s so that it returns the first element, then > overload to_a so that it'll return an array? If you know your data > and know you only want one element, having it short-circuit the search > is a Good Thing(TM) for performance. ;~) -sc Thanks, Sean. to_s currently returns the XML subtree, written out. EG: a = Element.new("a") a.add_element "b" a.to_s # -> "" to_a returns all of the children. Although it would be pretty easy to allow passing to_a an argument which is an XPath, this has the same problem as passing each() an XPath, in that to_a doesn't normally take arguments (in other core Ruby classes). -- --- SER