Created
March 26, 2016 22:25
-
-
Save shaselton/10d45a3aa328227ff137 to your computer and use it in GitHub Desktop.
Weekly Challenges 3-26-16
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 leftpad(str, len, ch = '') | |
return str if str.size >= len | |
(Array.new(len - str.size, ch) + str.split('')).join('') | |
end | |
puts leftpad('hello', 10, 'w') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment