我一直在查看一些编码解决方案,它们展示了“@”符号;但是,通过查阅文档,我似乎无法弄清楚该符号的作用。
在Elixir中,“@”符号有什么作用,为什么重要呢?
下面是一个例子:
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