πŸŽ“ A1Learner
πŸ”
0 of 54 lessons completed

Elixir Introduction

Elixir is a programming language for building reliable programs. Programs in Elixir print results with IO.puts.

IO.puts prints text

This program has one instruction. It prints a greeting.

IO.puts("Hello, Elixir!")

IO.puts prints a number

A number needs no quotes. Elixir prints it just as it is written.

IO.puts(42)

An empty string prints an empty line

IO.puts with an empty string between the quotes prints a blank line. The blank line sits between the other two lines in the output.

IO.puts("First")
IO.puts("")
IO.puts("Last")

Example

IO.puts("Welcome to Elixir")
IO.puts(2026)
IO.puts("Ready")

Key points

  • Program: a set of instructions the computer follows in order.
  • Value: a single piece of data, such as a number or a piece of text.
  • Use IO.puts to print a value and then move to a new line.
  • Text: words written inside double quotes, such as "Hello".
  • Number: a value written without quotes, such as 42.

In this example, the first line prints a piece of text. The second line prints a number. The third line prints one last piece of text, and the lines appear in the order they were written.

Note

Elixir prints text without the quotes around it.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

What does the code IO.puts("Hi") print?