I'm encountering a weird behaviour in Elixir when defining for example function default arguments or using head|tail in a list definitions.
This does not work and results in an error unexpected token: " "
:
def a(b \\ "test") do
b
end
But this one does:
def a(b \\"test") do
b
end
The difference being the whitespace character " "
preceding the default string argument "test"
Also this does not work and results in an error unexpected token: " "
:
[0 | [1,2,3,4,5]]
But this one does work:
[0 |[1,2,3,4,5]]
Once again the difference being the whitespace character " "
preceding the tail list definition [1,2,3,4,5]
The problem exists in IEX and compiled code. I'm running Elixir 1.4. My system is macOS Sierra and I'm using iTerm as my terminal app.
So the question is: is this the correct behaviour or is there something wrong for example in my environment and what it could possibly be? All the examples and guides allow whitespace in these positions but for some reason my environment does not. Is there something I can do about this?
Thank you in advance!
iex
? Do you still get the same error? (All 4 snippets are working fine for me.) – Dogbertunexpected token: " " (column 5, codepoint U+00A0)
It seems like the whitespace without tmux is somehow invalid. – veturi|
character since that one requires alt-key to be pressed and I just wasn't releasing the alt-key soon enough. And in case of macOS it produced 00A0 instead of normal space character. – veturi