From: Colin Bartlett Date: 2010-10-27T00:21:34+09:00 Subject: Re: Extraction of single subarrays from multidimensional array --000e0cd348641e14140493869f1d Content-Type: text/plain; charset=ISO-8859-1 On Tue, Oct 26, 2010 at 3:05 PM, Maurizio Cirilli wrote: > Thanks a lot Robert for your clear explanation and help. > In order to fully understand the code you provided, could you > please to tell what is the role of the asterisk in the > statement: > > a, b, c = *ss > > I did not find (or probably I just missed) this operator in the Ruby > docs I have. > Btw, bioinformatics libraries to Ruby community are provided by > the BioRuby project guys. > There's an explanation of *array in the online Programming Ruby, probably in the sections on assignment and/or method calls: I did think about searching for it, but the link below looks as though it has a reasonable explanation. Subject to correction by anyone more knowledgeable than me, the second statement below (extracted from the linked page) also applies to assignment, so you can do something like: aa = [1, 2] bb = [4, 5] cc = [7, 8] a, b, c, d, e, f, g = *aa, 3, bb, 6, *cc which sets a to 1, b to 2, c to 3, d to [4, 5], e to 6, f to 7, g to 8. As w_a_x_man pointed out, if the right hand side of an assignment statement is an array, and there are two or more variables on the left hand side of the assignment statement, then Ruby automatically expands the array for you, so you can omit the "*" operator if you want to.. http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Method_Calls ... Variable Length Argument List, Asterisk Operator The last parameter of a method may be preceded by an asterisk(*), which is sometimes called the 'splat' operator. This indicates that more parameters may be passed to the function. Those parameters are collected up and an array is created. ... The asterisk operator may also precede an Array argument in a method call. In this case the Array will be expanded and the values passed in as if they were separated by commas. ... --000e0cd348641e14140493869f1d--