Skip to content

Instantly share code, notes, and snippets.

@pkoch
Created May 5, 2017 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkoch/78d959bc4516238da62afcd277ce0592 to your computer and use it in GitHub Desktop.
Save pkoch/78d959bc4516238da62afcd277ce0592 to your computer and use it in GitHub Desktop.
pkoch  ~  iex
Erlang/OTP 19 [erts-8.3] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Interactive Elixir (1.4.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> defmodule User do
...(1)> defstruct name: "john"
...(1)> end
{:module, User,
<<70, 79, 82, 49, 0, 0, 8, 240, 66, 69, 65, 77, 69, 120, 68, 99, 0, 0, 0, 186,
131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105, 114, 95, 100, 111, 99, 115,
95, 118, 49, 108, 0, 0, 0, 4, 104, 2, ...>>, %User{name: "john"}}
iex(2)> User.new
** (UndefinedFunctionError) function User.new/0 is undefined or private
User.new()
iex(2)> %]User{}
** (SyntaxError) iex:2: unexpected token: ]
iex(2)> %User{}
%User{name: "john"}
iex(3)> %{%User{}| name: "poop"}
%User{name: "poop"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment