zip
![Wide documentation Importance_3](https://d2vfyqvduarcvs.cloudfront.net/images/importance_3.png?1349367920)
zip(*args)
public
Converts any arguments to arrays, then merges elements of self with corresponding elements from each argument. This generates a sequence of self.size n-element arrays, where n is one more that the count of arguments. If the size of any argument is less than enumObj.size, nil values are supplied. If a block is given, it is invoked for each output array, otherwise an array of arrays is returned.
a = [ 4, 5, 6 ] b = [ 7, 8, 9 ] [1,2,3].zip(a, b) #=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]] [1,2].zip(a,b) #=> [[1, 4, 7], [2, 5, 8]] a.zip([1,2],[8]) #=> [[4,1,8], [5,2,nil], [6,nil,nil]]
![Default_avatar_30](https://www.gravatar.com/avatar/0f164d278a84fd814b8f7cb228dab565?size=30&default=http://apidock.com/images/default_avatar_30.png)
Second example is correct
@taryneast, the second example is correct. The receiver’s #size limits the result’s.
nachokb
![Default_avatar_30](https://www.gravatar.com/avatar/eda85182ff398cbe4a4f70abf1b4c828?size=30&default=http://apidock.com/images/default_avatar_30.png)
![Default_avatar_30](https://www.gravatar.com/avatar/ba7bde80f192679378e884bf9a515f24?size=30&default=http://apidock.com/images/default_avatar_30.png)
re: question?
Nope. Read it again:
> This generates a sequence of self.size n-element arrays
If any of the arguments are longer than the receiver, the elements beyond the receiver’s length are ignored