Is it Possible to `def in()`

I get a SyntaxError for every variation of this that I can think of:

defmodule Tricky do
  def in(), do: :ok
end

Tricky.in |> IO.inspect
1 Like

in is probably a keyword because of constructs like 42 in [1, 2, 42, 86] so maybe not?

You can quote it so it doesn’t try to use the keyword

defmodule Tricky do
  def unquote(:in)(), do: :ok
end

Tricky.in |> IO.inspect #=> :ok
5 Likes

Thanks!

2 Likes