4

I have a situation where I am expecting some quoted elixir code to be an atom. If the wrong quoted code is passed in I want to raise an error and show what the wrong code was.

Simplest way to show what I need is with an example.

quoted_code = quote do: %{}
"%{}" = some_func(quoted_code)

1 Answer 1

7

You can achieve this with Macro.to_string/2

Macro.to_string(quote do: %{}) #=> "%{}"
Sign up to request clarification or add additional context in comments.

1 Comment

ok I am positive I tried that. Must have missed out a bracket round the quote or something.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.