Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Elixir Mini Introduction for Zürich Meetup

Elixir Mini Introduction for Zürich Meetup

Stefan Wintermeyer

February 20, 2017
Tweet

More Decks by Stefan Wintermeyer

Other Decks in Technology

Transcript

  1. Elixir is a functional, concurrent, general-purpose programming language that runs

    on the Erlang virtual machine (BEAM). https://en.wikipedia.org/wiki/Elixir_(programming_language)
  2. defmodule ModuleName do def hello do IO.puts "Hello World" end

    end http://elixir-lang.org/crash-course.html
  3. Why would I want to learn Elixir? Why invest the

    time and effort? I’m happy with Ruby and OO.
  4. iex(1)> a = 1 1 iex(2)> a = 2 2

    iex(3)> ^a = 3 ** (MatchError) no match of right hand side value: 3
  5. iex(1)> {a, b, c} = {10, 20, 30} {10, 20,

    30} iex(2)> {a, 20, c} = {10, 20, 30} {10, 20, 30} iex(3)>
  6. iex(1)> {a, b, c} = {10, 20, 30} {10, 20,

    30} iex(2)> {a, 20, c} = {10, 20, 30} {10, 20, 30} iex(3)> {a, 1, c} = {10, 20, 30} ** (MatchError) no match of right hand side value: {10, 20, 30}
  7. mix phoenix.new blog Y cd blog vim config/dev.exs brew install

    postgres brew services start postgres createuser -W --createdb blog demo mix ecto.create mix phoenix.gen.html Post posts subject body vim web/router.ex resources "/posts", PostController mix ecto.migrate mix phoenix.server Blog Example