轉至內容

Erlang 程式設計/變數

來自華夏公益教科書,一個開放世界的開放書籍

Erlang 中的變數

從技術上講,Erlang 中不存在多重賦值意義上的變數。其中有些虛擬變數可以在函式中取得匹配值。一旦匹配,它們的值就不會改變。erlang 中的變數必須以拉丁文 1 字元集的大寫字母開頭。

Latin-1 have the following classifications in Erlang:

Decimal       Example  Type of character
--------------------------------------------------
0  - 31                Control character
32                     Space
33 - 47                Punctuation
48 - 57        0-9     Digit
58 - 64                Punctuation
65 - 90        A-Z     Uppercase
91 - 96                Punctuation
97 - 122       a-z     Lowercase
123 - 127              Punctuation
Decimal       Example  Type of character
--------------------------------------------------
128 - 159              Control characters
160 - 191        - ¿   Punctuation 
192 - 214      À - Ö   Uppercase
               ×       Punctuation 
216 - 222      Ø - Þ   Uppercase 
223 - 246      ß - ö   Lowercase 	        
247            ÷       Punctuation 
248 - 255      ø - ÿ   Lowercase

變數示例

19> ß = 1.
** exception error: no match of right hand side value 1
20> Þ = a.
a
21> A = ß.
ß

說明

Þ is a capital letter so it can be a variable.
ß is not a capital letter so it can not be a variable, but it can be a symbol value.
華夏公益教科書