Greetings!
When assigning a value to an array as in the following, how could I replace the nils by 0?
nil
0
array = [1,2,3] array
There is no built-in function to replace nil in an array, so yes, map is the way to go. If a shorter version would make you happier, you could do:
map
array.map {|e| e ? e : 0}