Created
April 28, 2017 10:16
-
-
Save dharshan/e18b5e95710ae6ac5e78080f09c29908 to your computer and use it in GitHub Desktop.
Reverse input string if input string length is less than 4
This file contains hidden or 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 string_rev_if_4(input) | |
return input.reverse if input.length < 4 | |
input | |
end | |
string_rev_if_4("he") # "eh" | |
string_rev_if_4("hel") # "leh" | |
string_rev_if_4("hell") # "hell" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment