Skip to content

Instantly share code, notes, and snippets.

@ilyabrin
Forked from emad-elsaid/integer2array.rb
Created April 5, 2014 12:06
Show Gist options
  • Save ilyabrin/9991173 to your computer and use it in GitHub Desktop.
Save ilyabrin/9991173 to your computer and use it in GitHub Desktop.
class Integer
def to_a
arr = []
tmp = self
while tmp>0
arr << tmp%10
tmp /= 10
end
arr.reverse
end
end
# usage
print 32455.to_a
print 433456.to_a
print 345434.to_a.sort
print 344543.to_a.join '-'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment