Elixir quick start
Install for mac os
brew install elixir
Hello world for using vim, elixir
vim helloworld.elixir
current_process = self() # Spawn an Elixir process (not an operating system one!) spawn_link(fn -> send(current_process, {:msg, "hello world"}) end) # Block until the message is received receive do {:msg, contents} -> IO.puts(contents) end
$ elixir helloworld.elixir hello world
Hello world for iex
$ iex
iex(1)> nil iex(2)> current_process = self() #PID<0.104.0> iex(3)> nil iex(4)> # Spawn an Elixir process (not an operating system one!) nil iex(5)> spawn_link(fn -> ...(5)> send(current_process, {:msg, "hello world"}) ...(5)> end) #PID<0.114.0> iex(6)> nil iex(7)> # Block until the message is received nil iex(8)> receive do ...(8)> {:msg, contents} -> IO.puts(contents) ...(8)> end hello world :ok iex(9)>
or
IO.puts "Hello world"