(I've only been coding for a few weeks and this is my first question here, so please bear with me!)
In ruby, I know that you can initialize multiple variables on a single line like this:
a, b = 1, 2
However, I am wondering if it is possible to initialize multiple variables in a loop that also generates their names. Here's some pseudocode that explains what I mean:
For X between 0 and 3, even_X = X * 2
This would set even_0 == 0
, even_1 == 2
, even_2 == 4
, and even_3 == 6
.
I realize that one can achieve the same functionality by iteratively creating an array and then calling on its members, but I am still curious if there is a way to do this.
Thanks!