Jcm Mz <menzies.main / gmail.com> wrote:

> That I can see; Pragmatic Programming Ruby's, index, has reference to
> all sorts of symbols, but I can't find a explanation for a ',' seperator
> such as used in the following:
> 
>  var1, var2, var3 = 5

You've stumbled on one of Ruby's most elegant bits of syntactical
niceness: multiple assignment. It isn't the comma that's interesting
here so much as the equal-sign and how it distributes assignments based
on lists. Try these:

arr = [1, 2, 3]

# now look at what a, b, and c are after each of the following:

a, b, c = 1, 2, 3
a, b, c = [1, 2, 3]
a = b, c
a, b = b, a
a, b, c = arr
a, b, c = arr, 4
a, b, c = 4, arr
a, b, c = 4, *arr

m.

-- 
matt neuburg, phd = matt / tidbits.com, http://www.tidbits.com/matt/
Leopard - http://www.takecontrolbooks.com/leopard-customizing.html
AppleScript - http://www.amazon.com/gp/product/0596102119
Read TidBITS! It's free and smart. http://www.tidbits.com