From: bdarcus@... Date: 2005-06-27T03:35:39+09:00 Subject: Re: grouping/sorting [newbie question] Ryan Leavengood wrote: > bdarcus@gmail.com wrote: > > Thanks Ryan. Certainly less verbose than xslt! > > Generally so. Here is an article by Martin Fowler about his switch from > XSLT to Ruby for processing XML: > > http://www.martinfowler.com/bliki/MovingAwayFromXslt.html I saw that, though it'd be nice to have a fully functional example to try out. I couldn't manage how to get it working. Also, while Fowler's comments may apply well to XSLT 1.0, 2.0 adds a lot of power to the language. Still, it only goes so far of course, which is why I'm interested in Ruby and Python. > > What is the "||=[]" bit doing? > > That is a bit of a Ruby idiom (that comes from Perl I think.) It is > equivalent to var = var || []. If var is initially nil, it becomes a new > array, and whenever the above code is called again, var is just > re-assigned to itself. E.g. it only creates a new "group" if one doesn't already exist? Was wondering how to do that, so thanks for this! Bruce