Created
March 23, 2016 11:19
-
-
Save OleMchls/d3fc5fb0b02965fc6d92 to your computer and use it in GitHub Desktop.
elixir_string_match
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
# assign the prefix to a variable | |
iex(1)> pre = "he" | |
"he" | |
# a string match against the prefix works as expected | |
iex(2)> << "he", rest::binary >> = "hello" | |
"hello" | |
# a string match using the pinned prefix variable doesn't | |
iex(3)> << ^pre, rest::binary >> = "hello" | |
** (MatchError) no match of right hand side value: "hello" | |
# why? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment