Created
April 4, 2014 17:10
-
-
Save damianesteban/9978871 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
# Given a string, replace every instance of sad to happy | |
# | |
# add_more_ruby("The clowns were sad.") # => "The clowns were happy." | |
# add_more_ruby("The sad dad said sad stuff.") # => "The happy dad said happy stuff." | |
# add_more_ruby("Sad times are ahead!") # => "Happy times are ahead!" | |
def add_more_ruby(string) | |
string.gsub(/[sS]ad/, 'sad' => 'happy', 'Sad' => 'Happy') | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment