Skip to content

Instantly share code, notes, and snippets.

@wnuqui wnuqui/gist:2717282

Created May 17, 2012
Embed
What would you like to do?
where ruby's str#gsub can really prove that assumptions can really go wrong (any light?)
# ruby is 1.9.2p290
"Foo\n".gsub('\n', '') # => "Foo\n"
"Foo\n".gsub("\n", '') # => "Foo"
"Foo\n".gsub("\n", '') # => "Foo"
"Foo\n".gsub('\n', '') # => "Foo\n"
'Foo\n'.gsub("\n", '') # => "Foo\\n"
'Foo\n'.gsub('\n', '') # => "Foo"
# pastie here: http://pastie.org/3924412
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.