Skip to content

Instantly share code, notes, and snippets.

@alco
Created May 19, 2014 16:39
Show Gist options
  • Save alco/6a154dd7c415d57b01f1 to your computer and use it in GitHub Desktop.
Save alco/6a154dd7c415d57b01f1 to your computer and use it in GitHub Desktop.
# attr.exs
# using module attributes as compile-time constants
defmodule M do
@constant 13
def a, do: @constant
@constant 44
def b, do: @constant
end
IO.puts "a = #{M.a}; b = #{M.b}"
---
λ elixir attr.exs
a = 13; b = 44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment