ruby - Why does the Array allocation my_arr[0,3] work while my_arr[3,0] fails? -
I want to draw two values from one array based on their parameters. My_array [1,2] # = & my_array = ["a", "b", "c", "d", "e", "f", "g"]
Why is the final allocation failing to remove elements of 2 and 0?
I suspect that my operation really is not what I think is actually doing, because by connecting the third index, the whole thing fails:
My_array [1,2,3] # = & gt; ArgumentError: Wrong number of arguments (1..2 for 3) What am I really doing with syntax [var1, var2] and what should I do?
piece syntax:
This is a small syntax for my_array.slice (start, length); You should do this instead:
my_array.values_at (2, 0) => ["C", "A"] and
Comments
Post a Comment