The ? character in comprehensions

I got an answer right on one of my exercises just by guessing but want to understand Elixir.

Can you help me understand how this piece of code works

  defp converter do
    fn
      ?A -> ?U
      ?C -> ?G
      ?T -> ?A
      ?G -> ?C
    end
  end

I don’t understand the ? character and what it is doing here.

It returns the codepoint of the character…

iex> ?a
97

BTW You get the opposite with…

iex> List.to_string [?a]
"a"
4 Likes

Another way to get the string out of a codepoint, just for reference:

iex(4)> <<?ƒ::utf8>>
"ƒ"
iex(5)> <<?a::utf8>>
"a"
iex(6)> var = 5356
5356
iex(7)> <<var::utf8>>
"ᓬ"
5 Likes

Nice, thank you. First time working with encoding.