mardi 4 août 2015

extend array by n numbers while repeating elements

If I have an array like this

[1,2,3]*2 
#=> [1,2,3,1,2,3,1,2,3]

But I want to do it to certain length, that length is 1.5 the original array, preferably in one line

[1,2,3].size = 3
[1,2,3,1,2] or something like this



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire