HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to ElixirVariablesData TypesOperatorsStringsListsConditions (if / else)Iteration (Enum)Functions
REFERENCE
📖 Overview
🖥️ Output
📦 Variables & Types
🔢 Numbers & Math
✍️ String
📚 List & Enum
🔀 Condition
🧩 Function
Elixir›Operators

Operators

Math (+ - * / div rem), comparison (== < >), and logic (and or not).

Simple enough for a 5-year-old to understand

Math operators

/ always returns a float. Integer division is done with div(a,b), and remainder with rem(a,b).

Example code
1
IO.puts(7 + 3)
10
Output / Input10
2
IO.puts(7 / 2)
3.5 (always decimal)
Output / Input3.5 (always decimal)
3
IO.puts(div(7, 2))
3 (integer division)
Output / Input3 (integer division)
4
IO.puts(rem(7, 2))
1 (remainder)
Output / Input1 (remainder)
Output / Input
💡 Hint: Integer division is div(a,b), remainder is rem(a,b).

🎯 Exercise & Practice

Test what you've learned — answer, write code, check instantly. (1 left)

1.Print the remainder of the division of 23 by 4.

🎯 Expected output: 3

Loading editor…

About this topic

Some operators in Elixir are type-specific. String concatenation and list concatenation are done with different operators; using the wrong one will cause an error. While this distinction can be annoying at first, it makes the intent clear.

There are two families of logical operators. The word-form ones only accept booleans and will raise an error if given any other value. The symbol-form ones work with any value and behave according to Elixir's truthiness rules.

The pipe operator is Elixir's signature feature. It takes the result of the expression on the left and passes it as the first argument to the function on the right; thus, nested calls turn into a chain read from left to right. This is largely where Elixir code readability comes from.

What you will learn

  • String and list concatenation operators
  • Comparison operators
  • The two logical operator families
  • The pipe operator
  • Integer division functions

Who is this for?

  • Learners of Elixir syntax
  • Those getting errors during concatenation
  • First-time viewers of the pipe operator

When to use?

When sequential transformations are written with the pipe operator, there is no need to define intermediate variables, and the intent becomes visible.

When a value must strictly be a boolean, word-form operators should be used; type errors are caught immediately.

Common mistakes

Wrong

ad = "Ayşe"
IO.puts "Merhaba " + ad

The plus operator works only with numbers; when used with strings, it gives a "bad argument in arithmetic expression" error. There is a separate operator for string concatenation. Since plus does both in many languages, this mistake is made very often.

Correct

ad = "Ayşe"
IO.puts "Merhaba " <> ad

Wrong

liste = [1, 2]
IO.inspect liste <> [3]

The string concatenation operator is for binary data, it does not work on lists and raises an error. A separate operator is used for list concatenation. Mixing up the two requires remembering which one is for which type.

Correct

liste = [1, 2]
IO.inspect liste ++ [3]

Wrong

deger = 5
if deger and true do
  IO.puts "yes"
end

The word-form logical operator accepts only booleans; if a number is given, an "argument error" is received. If you want it to work with any value, you must use the symbol form. This distinction is deliberate: the strict form catches type errors early.

Correct

deger = 5
if deger && true do
  IO.puts "yes"
end

Frequently asked questions

What exactly does the pipe operator do?

It inserts the result of the expression on the left as the first argument of the function call on the right. It turns nested calls into a flat chain; the reading direction becomes left to right instead of inside out.

What is the difference between double equals and triple equals?

Double equals compares numeric values ignoring type differences; an integer and a float with the same value are considered equal. Triple equals also compares the type and in this case considers them not equal.

Which function is used to get the remainder?

There are separate functions for remainder and integer division; the percent sign is part of Elixir's matching syntax, not a remainder operator. This is a point frequently confused by people coming from other languages.

Summary

String and list concatenation operators are different.

Plus only works with numbers.

Word-form logical operators are strict.

The pipe operator turns calls into a chain.

Remainder and integer division are separate functions.

HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code