What do these operators mean in Elixir? ~>>, <<~
They are listed here http://elixir-lang.org/getting-started/basic-operators.html
I get the following error:
iex(28)> b=1
1
iex(29)> b~>>1
** (CompileError) iex:29: undefined function ~>>/2
There are some operators that currently have no meaning, but you can use them in macros you define or just define them as functions. For example:
defmodule Operators do
def a ~>> b do
a + b
end
end
defmodule Test do
def test do
import Operators
1 ~>> 2
end
end
IO.inspect(Test.test) # => 3
The general idea is that Elixir wants to avoid operator proliferation (think libraries that define dozens of new operators) so when defining your macros you need to use the ones that are already there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With