I am writing a ruby method as follows:
def build_array(word)
word_copy = word
array = []
length = word_copy.length
for i in 1..length do
array[i] = word_copy % 10
word_copy = word_copy/10;
end
puts array
end
I would like to create an iterator which counts from 1 to the number of digits in a Bignum
.
Bignum.length
is not valid ruby. Alternatively, is there a way to bust up a Bignum
into an array of its constituent digits (Which is what I am trying to implement).
Thanks!