Created
August 21, 2015 23:44
-
-
Save eternal44/450f1b7d72599aa01e57 to your computer and use it in GitHub Desktop.
Refactored exercise
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
# doctest: correct output | |
# >> split_message("Welcome to the forum.\nHere you can learn Ruby.\n"\ | |
# "Along with other members.\n") | |
# => ["Line 1: Welcome to the forum.", "Line 2: Here you can learn Ruby.", "Line 3: Along with other members."] | |
def split_message(message) | |
message.split("\n").collect.with_index { |i, j| "Line #{j + 1}: " + i } | |
end | |
split_message("Welcome to the forum.\nHere you can learn Ruby.\n"\ | |
"Along with other members.\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment