Title here
Summary here
Elixir has various value types including strings, integers, floats, booleans, etc. Here are a few basic examples.
defmodule Values do
def main do
# Strings, which can be concatenated with <>
IO.puts("elixir" <> "lang")
# Integers and floats
IO.puts("1+1 = #{1 + 1}")
IO.puts("7.0/3.0 = #{7.0 / 3.0}")
# Booleans, with boolean operators as you'd expect
IO.puts(true and false)
IO.puts(true or false)
IO.puts(not true)
end
end
Values.main()
To run the program, save it as values.exs
and use the elixir
command:
$ elixir values.exs
elixirlang
1+1 = 2
7.0/3.0 = 2.3333333333333335
false
true
false
In Elixir, we don’t typically compile programs into standalone binaries. Instead, we run them directly with the elixir
command or use them as part of a larger project managed by tools like Mix.
This example demonstrates basic value types in Elixir, including strings, numbers, and booleans. Note that Elixir uses <>
for string concatenation, and
, or
, and not
for boolean operations, and #{...}
for string interpolation.