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

Intro Elixir

Intro Elixir

Intro bien simple à Elixir dans le cadre du WAQ 2016 et du Hackatown 2017

Simon Prévost

February 16, 2017
Tweet

More Decks by Simon Prévost

Other Decks in Programming

Transcript

  1. PROGRAMMATION ORIENTÉE OBJET class User < ActiveRecord::Base include Extensions::UserStatus include

    Extensions::UserEntity include Extensions::UserRelationTeams include Extensions::UserRelationRoles include Extensions::UserRelationGames include Extensions::InscriptionStatesScopable include Extensions::UserSearchScopable include Handlebarer::Serialize extend FriendlyId
  2. a = 2 b = lambda { a * 2

    } b.call() # 4 a = 3 b.call() # 6
  3. a = 2 b = fn -> a * 2

    end b.() # 4 a = 3 b.() # 4
  4. defp build_if(condition, do: do_fun, else: else_fun) do optimize_boolean(quote do case

    unquote(condition) do x when x in [false, nil] -> unquote(else_fun) _ -> unquote(do_fun) end end) end
  5. defp build_if(condition, do: do_fun) do build_if(condition, do: do_fun, else: nil)

    end defp build_if(condition, do: do_fun, else: else_fun) do optimize_boolean(quote do case unquote(condition) do …