I’m trying to create an array that has numerous entries are are all the same value. I’m trying to instantiate it without typing out some repetitive data.
This is in a pattern, so I’d rather not use .do or .collect or something like that.
The array I’d like to create, for example is:
[0.9, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3]
However, if it write:
0.9 ++ 0.3 ! 6
0.9 ++ 0.3.dup(6)
I receive an error:
ERROR: Message '++' not understood.
I’ve tried sticking parens around stuff in various combinations, but I still get the same error.
What’s throwing me off though is that having the values in the opposite order works fine. This gives me the array that I want:
0.3 ! 6 ++ 0.9
Does anyone know why it works one way, but the other?
Also, can anyone recommend a different way to quickly create an array like this?