Skip to content

Instantly share code, notes, and snippets.

@eternal44
Created August 23, 2015 20:41
Show Gist options
  • Save eternal44/4c86061d6d21120f6b5a to your computer and use it in GitHub Desktop.
Save eternal44/4c86061d6d21120f6b5a to your computer and use it in GitHub Desktop.
Comparing "each_line" with "collect"
def split_message(message)
output_line = ""
message.each_line.with_index(1) do |line, index|
output_line << "Line #{index}: #{line}"
end
output_line
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment