Skip to content

Instantly share code, notes, and snippets.

@rodesousa
Last active June 26, 2019 16:26
Show Gist options
  • Save rodesousa/397112294929c035f8d969e36c8294cb to your computer and use it in GitHub Desktop.
Save rodesousa/397112294929c035f8d969e36c8294cb to your computer and use it in GitHub Desktop.
some elixir code
# to know type
i type
IO.inspect type
# range
players =
1..12
|> Enum.map(fn _ -> %Player{} end)
# Ecto // db
mix ecto.create
# Struct
defmodule User do
defstruct email: nil
end
%User{email: "c@c.com"} = struct(%User{}, email: "c@c.com")
# Help
%User{email: "a@a.co"} = %{ %User{} | email: "a@a.co" }
%User{email: "b@b.com"} = Map.put(%User{}, :email, "b@b.com")
# Default
def test(a \\ "aze") do
IO.puts(a)
end
# Help
h(Map.replace!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment