Skip to content

Instantly share code, notes, and snippets.

@wnuqui
Created May 17, 2012 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wnuqui/2717282 to your computer and use it in GitHub Desktop.
Save wnuqui/2717282 to your computer and use it in GitHub Desktop.
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