3
3

More than 5 years have passed since last update.

Elixir のオペレータについて

Last updated at Posted at 2015-06-15

Elixir のオペレータについての覚え書き。

iex(1)> 1 = 1
1

iex(2)> 1 == 1
true

iex(3)> 1 == 1.0
true

iex(4)> 1 === 1.0
false

iex(4)> true == true
true

iex(6)> true == false
false

iex(7)> true or false
true

iex(8)> true and false
false

変わりどころで下記のオペレータ。
Stringの連結。リストの連結。リストの差分。含まれているかどうか。

iex(1)> "Hello " <> "World!!"
"Hello World!!"

iex(2)> [1,2,3] ++ [4,5,6]   
[1, 2, 3, 4, 5, 6]

iex(3)> [1,2,3] -- [1,2]  
[3]

iex(4)> [1,2] -- [1,2,3]  
[]

iex(5)> [1,2,4] -- [1,2,3]
[4]

iex(6)> 2 in [1,2,3,4,5]
true

iex(7)> 6 in [1,2,3,4,5]
false

なるほど。なかなか・・・。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3