2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ここまでのあらまし

こちら のページを参照しながらElixirの基本について備忘録的にドキュメントをしたためています。今回は演算子を扱います

本題

四則演算については前回暑かったので割愛します。

文字列をつなぐ演算子は<>

iex > name ="kento"
"kento"
iex > "my name is "<> name
"my name is kento"

アトムを加える場合は#{}で囲んで。

iex> "hello #{:world}"
"hello world"

論理和演算子||と論理積演算子&&について。

iex> -1 || true
-1
iex> false || 2
2 
iex > nil && 3
nil
iex > true && 4
4

左オペランドを評価し、||はtrueなら左オペランドを、falseなら右オペランドを返す。
&&はその逆。

比較演算子について、だいたい覚えてるからいいかな...と思いましたが異なる型のデータでも大小比較ができるようです。

データの大小について、

number < atom < reference < function < port < pid < tuple < map < list < bitstring

という決まりがあるようです。

#編集後記

突っ走って本日3本目のドキュメント更新です。
基本的には自分のために書いていますがどなたかのご理解の一助のきっかけになったら幸いです。
うまずたゆまず、頑張ります。
Kento Mizuno

2
0
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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?