Additional Bonus for you flatten. Flatten, as name suggests flatten out an array no matter how much nesting level is involved for an array. Below is the example for 3 level nesting
a=[[1,2,3],[4,[5,[6,7]]]]b=a.flatten# b = [1, 2, 3, 4, 5, 6, 7]
Also, you can do a.flatten!, which will overwrite a itself and assign the new value.
a=[[1,2,3],[4,[5,[6,7]]]]a.flatten!# a = [1, 2, 3, 4, 5, 6, 7]
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Additional Bonus for you
flatten
. Flatten, as name suggests flatten out an array no matter how much nesting level is involved for an array. Below is the example for 3 level nestingAlso, you can do
a.flatten!
, which will overwritea
itself and assign the new value.