LoginSignup
6
3

More than 5 years have passed since last update.

[Elixirメモ] 1.ざっくりインストールとIntroduction編

Last updated at Posted at 2017-06-01

Elixirのチュートリアル
Getting Startedのメモであります

1-1.まずはインストール

の、前に
elixir -v で、導入済みのElixirのバージョンを確認ができる。
今回は 「Elixir 1.4.4」 を導入。

  • MacOSでインストール
    • 安定のHomebrew brew install elixir
    • ちなみに exenv を使うと複数のバージョンが管理できるみたい。env系すごい。
    • exenv を使う場合は erlang を brew 等手動で入れる必要があるので注意。
    • (上記のやり方で elixir を使う場合は erlang も自動で入れてくれる)

Elixirをインストールすると iex elixir elixirc が実行できる。

1-2.インタラクティブモード<iex>

$ iex でインタラクティブモード(対話モード)起動

iex起動
Interactive Elixir (1.4.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> 

起動完了。 「 Ctrl + C 」を2回押しで終了できる。

起動できたのでとりあえず簡単に四則計算と文字列を表示。

四足計算と文字列表示
iex(1)> 5 + 5
10
iex(2)> 5 - 5
0
iex(3)> 5 * 5
25
iex(4)> 5 / 5
1.0
iex(5)> "Hello" <> "world!!"
"Helloworld!!"

除算は実数になるっぽい。
文字列は<>でくっつけられる。

1-3.スクリプトを動かす<xxx.exs>

simple.exs を用意。

simple.exs
IO.puts "Hello world
from Elixir"

elixir simple.exs で実行

simple.exs実行
$ elixir simple.exs 
Hello world
from Elixir

IO.putsで色々出力な感じかな?

おしまい。

「2.Basic types」 へつづく?

6
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
6
3