elixir
Elixir is a functional programming language created by
atoms
Atoms are constants whose names are their values.
:x :x
:x == :y false
string manipulation
name = "David"
"Hello #{name}" "Hello David"
"Hello " <> name "Hello David"
grimoire
labeling IO.inspect
IO.inspect("meow", label: "cat")
cat: "meow"
truncating maps in IO.inspect
IO.inspect(["Hello", "world"], limit: 1) # :infinity
["Hello", …]
["Hello", "world"]
IO.inspect
in colour
IO.inspect(_, syntax_colors: IO.ANSI.syntax_colors())
using cassettes
describe "function/1" do
test "case" do
use_cassette "path/cassette", match_requests_on: [:headers] do
# …
end
end
end
def check(condition) do
if condition, do: "yes", else "no"
end
def check(true), do: "yes"
def check(false), do: "no"
mix
Mix is a build tool for Elixir and facilitates creation, compilation, testing, and dependency management.
install packages
mix deps.get
checking code coverage
MIX_ENV=test mix coveralls.detail --filter file.ex
list outdated dependencies and purge unused dependencies
mix hex.outdated
mix deps.clean --unlock --unused
resources
- Introduction — Elixir
- HexDocs, package docs
- Phoenix Framework, web framework