I am calling to_s
within a method:
$ def my_function(num)
$ number = num.to_s.split(//)
$ puts number
$ end
$ my_function(233)
2
3
3
# => nil
It looks to me like within the function, no array is created since the output is nil
. Why is an array of strings not created when to_s.split(//)
is called inside a method?
Also, why is the output for puts number
seemingly just each digit on its own line? Do I need to explicitly create the array within the function and then explicitly push the split number into it?