I have been looking through some coding solutions and they show the "@" symbol; however, I can't really seem to figure out what that symbol does by looking through documentation.
What does the @ symbol do in Elixir, and why is it important?
Here is an example:
defmodule RNATranscription do
@dna_nucleotide_to_rna_nucleotide_map %{
# `G` -> `C`
71 => 67,
# `C` -> `G`
67 => 71,
# `T` -> `A`
84 => 65,
# `A` -> `U`
65 => 85
}
@doc """
Transcribes a character list representing DNA nucleotides to RNA
## Examples
iex> RNATranscription.to_rna('ACTG')
'UGAC'
"""
@spec to_rna([char]) :: [char]
def to_rna(dna) do
dna
|> Enum.map(&get_rna_for_dna/1)
end
defp get_rna_for_dna(dna_nucleotide) do
@dna_nucleotide_to_rna_nucleotide_map[dna_nucleotide]
end
end