On Thu, Apr 16, 2009 at 3:59 AM, Adam Akhtar <adamtemporary / gmail.com> wrote: > Ahh i didnt know you could use scan like that with blocks and > variables...thats going to come in very handy indeed. You probably realise this, but for the benefit of newbies, there are three different things going on there. Firstly, if the regexp passed to scan has groups, the returned values are arrays with one element per group (corresponding to $1, $2, ...). Secondly, if you pass a block to scan, it yields its return values one by one, rather than just accumulating them into an array. Thirdly, if you yield multiple values to a block, the block can capture them either as an array, or in multiple parameters. The beauty of ruby is how well all these different features fit together to give the elegant scan syntax. martin