Created
November 15, 2008 20:53
-
-
Save sporkmonger/25325 to your computer and use it in GitHub Desktop.
Split Weirdness
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
# WHY? | |
"/foo/bar/baz".split("/") | |
# => ["", "foo", "bar", "baz"] | |
"/foo/bar/baz/".split("/") | |
# => ["", "foo", "bar", "baz"] | |
"foo/bar/baz/".split("/") | |
# => ["foo", "bar", "baz"] | |
# What's the best way to get this result? | |
"/foo/bar/baz".split_alternative("/") | |
# => ["", "foo", "bar", "baz"] | |
"/foo/bar/baz/".split_alternative("/") | |
# => ["", "foo", "bar", "baz", ""] | |
"foo/bar/baz/".split_alternative("/") | |
# => ["foo", "bar", "baz", ""] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment