Private And Public Functions In Elixir
Elixir language supports public and private functions. The private function could only be called from functions in the same module. This post is part of the functional language series, and it is based on the remarkable book Elixir In Action by Sasa Juric.
We defined in the module Visibility two functions:
- profit() is private function that returns value 40 million
- cro_tax() is a public method that returns Croatian tax on company profit.
How we use them in IEx:
- how to define a private function
- what is the public method
- error code when you call the private function
Originally published at https://blog.tentamen.eu on June 11, 2020.