On Elixir Pt. 2

Jan 3, 2025

Go ahead and create a file with the name hello_world.ex. Open this file in your favorite text editor and write the following code in it:

IO.puts("hello, world")

Let’s run this program, and then I’ll explain. To run the program, use the following command (elixir followed by the name of the program):

$ elixir hello_world
hello, world

Explanation

IO.puts is a function in the Elixir programming language that prints a string to the terminal with a newline at the end.

  • IO is the module that contains the puts function.
  • puts is the function responsible for outputting the string.

Elixir is a functional programming language that organizes code into modules, and functions are defined inside these modules. In this case, IO is the module, and puts is the function that performs the printing.

Tags: elixir