Editing
Elixir Data Types
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
= Floats = Floats in Elixir are represented by the `Float` module and are implemented as double-precision floating-point numbers according to the IEEE 754 standard. === Atoms === Atoms are constants whose name is their own value. They are often used to represent states, as function arguments, or as keys in maps and keyword lists. Atoms are defined by a leading `:` and can contain letters, numbers, underscores, and `@`. Examples of atoms include `:ok`, `:error`, or `:apple`. === Booleans === Elixir provides the boolean data type with two possible values: `true` and `false`. Booleans are commonly used in conditional statements and logical operations. === Strings === Elixir supports string literals, which are enclosed in double quotes (`"`) or triple double quotes (`"""`). Strings are represented as UTF-8 encoded binaries. Elixir also provides a wide range of string manipulation functions through the `String` module for tasks such as concatenation, interpolation, and pattern matching. === Lists === Lists in Elixir are ordered collections of elements. They can contain elements of different data types and are enclosed in square brackets (`[` and `]`). Elixir lists support pattern matching, concatenation, and a variety of functions such as `hd` (returns the head element) and `tl` (returns the tail elements). === Tuples === Tuples in Elixir are ordered collections of elements enclosed in curly braces (`{` and `}`). Unlike lists, tuples are stored contiguously in memory and have a fixed size. Tuples can contain elements of different data types and are commonly used to return multiple values from a function or represent a collection of related values. === Maps === Maps in Elixir are key-value data structures where keys and values can be of any data type. They are represented by a `%{}` syntax and are enclosed in curly braces. Maps can be used to store and retrieve values efficiently and support functions like `put`, `get`, `update`, and `delete` for manipulation. === Binaries === Binaries in Elixir are sequences of bytes. They are represented using the `<<>>` syntax and can contain any data, including integers, floats, and strings. Elixir provides a set of functions in the `Bitwise` module to manipulate binary data, such as bitwise operators, binary pattern matching, and bit string comprehensions. === PID === A PID (process identifier) in Elixir represents a reference to a process. It is created when a process is spawned and can be used to send messages or monitor the process. === References === References in Elixir are unique identifiers that are guaranteed to be unique across all nodes in a distributed system. They can be created using the `make_ref/0` function. References are commonly used for generating unique values, as part of supervisor strategies, or in distributed transactions. === Functions === Functions in Elixir are first-class citizens and can be assigned to variables, passed as arguments, or returned from other functions. They are the building blocks of functional programming. Elixir supports anonymous functions as well as named functions defined using the `def` keyword. Functions can have multiple clauses and pattern matching is used to determine which one to invoke. == Conclusion == In this article, we have explored the different data types available in Elixir. Understanding these data types and their characteristics is essential for writing expressive and robust Elixir code. For further information on specific data types or advanced topics, refer to the related articles on this Elixir wiki. {{Languages|Elixir Data Types}}
Summary:
Please note that all contributions to Elixir Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Elixir Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information