1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# Strings
"hello" # string
'hello' # char list
# Multi-line strings
"""
I'm a multi-line
string.
"""
# Strings are all encoded in UTF-8:
"héllò" #=> "héllò"
#String相加
'hello ' ++ 'world' #'hello world'
"a" <> "b" #ab
# Strings are really just binaries, and char lists are just lists.
<<?a, ?b, ?c>> #=> "abc"
[?a, ?b, ?c] #=> 'abc'
# `?a` in elixir returns the ASCII integer for the letter `a`
?a #=> 97
# 數字
3 # integer
0x1F # integer
3.0 # float
# Atoms, `:`開頭 , 變數名稱就是變數本身
:hello
:"變數"
<<1,2,3>> # binary
# Tuples that are stored contiguously in memory.
{1,2,3} # tuple
# Lists that are implemented as linked lists.
[1,2,3] # list
[1,2,3] ++ [4,5] #=> [1,2,3,4,5]
1..3 # range -> [1,2,3]
|