Skip to content

Latest commit

 

History

History
9 lines (6 loc) · 487 Bytes

elixir-constants.md

File metadata and controls

9 lines (6 loc) · 487 Bytes

Constants

There are 2 ways to create constants/global variables in Elixir:

  • by creating a Module attribute
  • with help of metaprogramming(Uhhhh)

Module attribute value exists only during compilation time. Also it can't be accessed outside the module in which it's declared.

By creating abstract layer function to return constant value. This approach uses macros and it's accessible outside of the declared module. More details here.