Created
August 31, 2014 09:07
-
-
Save nextacademy-private/28e7792a00684332b97c 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 destroy_message(string) | |
#TODO: return the part a string without the message | |
end | |
def destroy_message!(string) | |
#TODO: remove the message from string destructively! | |
end | |
# Driver code... | |
string = "this message will self-destruct: you can't hug every cat" | |
original_string = string.dup | |
puts destroy_message(string) == "this message will self-destruct:" | |
puts string == original_string # we shouldn't modify the string passed to destroy_message | |
string = "this has no message" | |
original_string = string.dup | |
puts destroy_message(string) == string | |
puts string == original_string # we shouldn't modify the string passed to destroy_message | |
string = "this message will self-destruct: you can't hug every cat" | |
original_string = string.dup | |
destroy_message!(string) | |
puts string == "this message will self-destruct:" | |
puts string != original_string | |
string = "this has no message" | |
result = destroy_message!(string) | |
puts result.nil? | |
puts string == string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment