How to split digits of an integer into different variable in Ruby

1 Answer

0 votes
n = 837

first, second, third = n.to_s.split('')

puts first, second, third



 
 
#
# run:
# 
# 8
# 3
# 7
#

 



answered Oct 17, 2021 by avibootz
...