Last active
April 16, 2016 01:50
-
-
Save kaochenlong/fad0bd1c37b64f7e7ce43a7b18d582a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_zero(n, digit = 0) | |
"#{"0" * digit}#{n}"[-digit..-1] | |
end | |
puts add_zero(3, 5) #=> 00003 | |
puts add_zero(13, 8) #=> 00000013 | |
puts add_zero(43, 10) #=> 0000000043 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment