Private And Public Functions In Elixir

TL;DR

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:

Remember

  • 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.

--

--

--

Founder of Tentamen, software testing agency.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How I have downloaded 400+ free Springer books using python

Database Connections in Python: Extensible, Reusable, and Secure

Using the new C# Azure.Data.Tables SDK with Azure Cosmos DB

Labels & Collections

Create Live Tile to Display Network Data Usage in Windows 10

Windows Settings

How to embed Unity 3D in a native Android app

Software Developers — the 21st century’s most in-demand professionals

Jenkins with Dockerhub integration

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
Karlo Smid

Karlo Smid

Founder of Tentamen, software testing agency.

More from Medium

Intro to Elixir Functions

In Phoenix, how does the router, controller, template, and view code work together to render…

An opinionated Elixir Style Guide #2

Ranked data with Ecto window Queries