From: Nat Pryce Date: 2001-11-14T19:12:51+09:00 Subject: [ruby-talk:25155] Re: REXML behavior change RFC I have two comments. First, [] returning multiple objects feels a bit odd to me. I'd prefer a well named method over an operator. Secondly, returning an array of elements would be inefficient when there are many matches to the XPath argument. How about the method taking an optional block, and yielding each match to the block if a block is present, and returning an array if the block is not present. This is a common Ruby idiom. Cheers, Nat. ________________________________ Dr. Nathaniel Pryce B13media Ltd. 40-41 Whiskin St, London, EC1R 0BP, UK http://www.b13media.com XP Day, London, UK. 15th December 2001. http://xpday.xpdeveloper.com/ ----- Original Message ----- From: "James Britt (rubydev)" To: "ruby-talk ML" Sent: Wednesday, November 14, 2001 2:11 AM Subject: [ruby-talk:25131] RE: REXML behavior change RFC > I think this is a good thing; when using XPath I've gotten accustomed to getting back a nodeList, which the code then iterates over. > > Getting back an array of node objects would be nice. > > James > > > -----Original Message----- > > From: Sean Russell [mailto:ser@efn.org] > > Sent: Tuesday, November 13, 2001 10:30 AM > > To: ruby-talk ML; undisclosed-recipients: > > Subject: [ruby-talk:25042] REXML behavior change RFC > > Importance: High > > > > > > Hi, > > > > This is a general request for comments to all of you who are using REXML. > > > > The current behavior of Element.elements[] is to return the first > > matching element. I propose changing this behavior so that it returns an > > array of matching elements. This will allow you to write: > > > > myel.elements["//blah"].each { |element| ... } > > > > rather than: > > > > myel.elements.each("//blah") {|element|... } > > > > My reasons for wanting the change are: > > > > 1) I was never comfortable with extending "each" to taking an argument in > > the first place. I'll deprecate each(...), but will leave it for backwards > > compatibility. > > > > 2) I find that I always start to use the first form, then have to rewrite > > it to the second. > > > > Thanks. > > > > --- SER > > > > > > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- > > http://www.newsfeeds.com - The #1 Newsgroup Service in the World! > > Check out our new Unlimited Server. No Download or Time Limits! > > -----== Over 80,000 Newsgroups - 19 Different Servers! ==----- > > > >