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 on June 11, 2020.

Founder of Tentamen, software testing agency.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store