<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Carlos Ramírez</title>
    <description>The latest articles on DEV Community by Carlos Ramírez (@calbertora).</description>
    <link>https://dev.to/calbertora</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F168026%2F12ac2bc6-3127-4b5e-b01a-98ada7171985.JPEG</url>
      <title>DEV Community: Carlos Ramírez</title>
      <link>https://dev.to/calbertora</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/calbertora"/>
    <language>en</language>
    <item>
      <title>Elixir data types Part 2</title>
      <dc:creator>Carlos Ramírez</dc:creator>
      <pubDate>Mon, 08 May 2023 14:51:41 +0000</pubDate>
      <link>https://dev.to/calbertora/elixir-data-types-part-2-7pn</link>
      <guid>https://dev.to/calbertora/elixir-data-types-part-2-7pn</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In the &lt;a href="https://dev.to/calbertora/elixir-data-types-2i6d"&gt;previous part&lt;/a&gt;, we learned about some basic data types in Elixir, such as atoms and booleans. In this part, we will explore some more data types that are commonly used in Elixir programs: integers, floats, and strings.&lt;/p&gt;

&lt;h2&gt;
  
  
  Integers/Floats
&lt;/h2&gt;

&lt;p&gt;Integers and floats are numeric data types that represent whole numbers and decimal numbers respectively. They can be used for arithmetic operations, such as addition, subtraction, multiplication, and division. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elixir"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Integers&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="mi"&gt;12&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="mf"&gt;5.0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elixir"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Floats&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;1.5&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;2.5&lt;/span&gt;
&lt;span class="mf"&gt;4.0&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;3.14&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;
&lt;span class="mf"&gt;2.14&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;2.0&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;1.5&lt;/span&gt;
&lt;span class="mf"&gt;3.0&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;10.0&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;3.0&lt;/span&gt;
&lt;span class="mf"&gt;3.3333333333333335&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that dividing two integers always returns a float, even if the result is a whole number. This is because Elixir uses floating-point arithmetic to perform division, which can introduce some rounding errors. If you want to get an integer result from division, you can use the div/2 function instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elixir"&gt;&lt;code&gt;&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;div&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;div&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="mi"&gt;3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use the rem/2 function to get the remainder of a division:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elixir"&gt;&lt;code&gt;&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;rem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;rem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Integers and floats can also be written in different formats, such as binary, octal, hexadecimal, scientific notation, and underscore separators. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elixir"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Binary&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mb"&gt;0b1010&lt;/span&gt; &lt;span class="c1"&gt;# equivalent to 10 in decimal&lt;/span&gt;
&lt;span class="mi"&gt;10&lt;/span&gt;

&lt;span class="c1"&gt;# Octal&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mo"&gt;0o12&lt;/span&gt; &lt;span class="c1"&gt;# equivalent to 10 in decimal&lt;/span&gt;
&lt;span class="mi"&gt;10&lt;/span&gt;

&lt;span class="c1"&gt;# Hexadecimal&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mh"&gt;0xA&lt;/span&gt; &lt;span class="c1"&gt;# equivalent to 10 in decimal&lt;/span&gt;
&lt;span class="mi"&gt;10&lt;/span&gt;

&lt;span class="c1"&gt;# Scientific notation&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;1.0e3&lt;/span&gt; &lt;span class="c1"&gt;# equivalent to 1000.0 in decimal&lt;/span&gt;
&lt;span class="mf"&gt;1000.0&lt;/span&gt;

&lt;span class="c1"&gt;# Underscore separators&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1_000_000&lt;/span&gt; &lt;span class="c1"&gt;# equivalent to 1000000 in decimal&lt;/span&gt;
&lt;span class="mi"&gt;1000000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Strings
&lt;/h2&gt;

&lt;p&gt;Strings are data types that represent sequences of characters enclosed in double quotes. They can be used for storing and manipulating text data, such as names, messages, and commands. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elixir"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Strings&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"Hello"&lt;/span&gt;
&lt;span class="s2"&gt;"Hello"&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"World"&lt;/span&gt;
&lt;span class="s2"&gt;"World"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Strings can be concatenated using the &amp;lt;&amp;gt; operator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elixir"&gt;&lt;code&gt;&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"Hello"&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"World"&lt;/span&gt;
&lt;span class="s2"&gt;"Hello World"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Strings can also be interpolated using the #{} syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elixir"&gt;&lt;code&gt;&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Alice"&lt;/span&gt;
&lt;span class="s2"&gt;"Alice"&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"Hello &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="s2"&gt;"Hello Alice"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Strings are encoded using UTF-8, which means they can contain any Unicode character:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elixir"&gt;&lt;code&gt;&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"こんにちは"&lt;/span&gt;
&lt;span class="s2"&gt;"こんにちは"&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"👋"&lt;/span&gt;
&lt;span class="s2"&gt;"👋"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Strings are also binaries, which means they are sequences of bytes that can be manipulated at a low level using binary pattern matching and functions from the Bitwise module. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elixir"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Binary pattern matching on strings&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;first&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;utf8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;binary&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Hello"&lt;/span&gt;
&lt;span class="s2"&gt;"Hello"&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;first&lt;/span&gt; &lt;span class="c1"&gt;# the code point of the first character 'H'&lt;/span&gt;
&lt;span class="mi"&gt;72&lt;/span&gt; 
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt; &lt;span class="c1"&gt;# the rest of the string 'ello'&lt;/span&gt;
&lt;span class="s2"&gt;"ello"&lt;/span&gt;

&lt;span class="c1"&gt;# Bitwise operations on strings&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"Hello"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="c1"&gt;# bitwise AND operation on each byte of the string with 255 &lt;/span&gt;
&lt;span class="s2"&gt;"Hello"&lt;/span&gt;
&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"Hello"&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="c1"&gt;# bitwise left shift operation on each byte of the string by one bit &lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;136&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;162&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;162&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;162&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;176&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;In this part, we learned about three more data types in Elixir: integers, floats, and strings. Integers and floats are numeric data types that can be used for arithmetic operations and can be written in different formats. Strings are sequences of characters that can be used for text data and can contain any Unicode character. Strings are also binaries that can be manipulated at a low level using binary pattern matching and bitwise operations.&lt;/p&gt;




&lt;p&gt;Thanks for reading! My goal is to make Elixir accessible and easy to understand for everyone. If you have any questions or feedback, please don't hesitate to reach out. And be sure to check back regularly for more articles on &lt;a href="https://dev.to/calbertora"&gt;https://dev.to/calbertora&lt;/a&gt;, as I strive to make each post as clear and readable as possible.&lt;/p&gt;

</description>
      <category>elixir</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Elixir data types Part 1</title>
      <dc:creator>Carlos Ramírez</dc:creator>
      <pubDate>Tue, 02 May 2023 13:53:01 +0000</pubDate>
      <link>https://dev.to/calbertora/elixir-data-types-2i6d</link>
      <guid>https://dev.to/calbertora/elixir-data-types-2i6d</guid>
      <description>&lt;h2&gt;
  
  
  Introduction:
&lt;/h2&gt;

&lt;p&gt;When it comes to programming in Elixir, understanding the different data types is crucial. We'll cover the main data types in Elixir and how to work with them effectively. In this first part, we'll explore atoms and booleans, two of the simplest yet most fundamental data types in Elixir.&lt;/p&gt;

&lt;h2&gt;
  
  
  Atoms
&lt;/h2&gt;

&lt;p&gt;Atoms are constants that represent names or values. They start with a colon (:) followed by a sequence of alphanumeric characters, underscores, or @. For example, &lt;code&gt;:hello&lt;/code&gt;, &lt;code&gt;:ok&lt;/code&gt;, &lt;code&gt;:user_id&lt;/code&gt;, and &lt;code&gt;:@name&lt;/code&gt; are all valid atoms.&lt;/p&gt;

&lt;p&gt;Atoms are useful for naming things, such as keys in maps or messages in processes. Atoms are also used to represent the result of some operations, such as &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt; for boolean expressions, or &lt;code&gt;:error&lt;/code&gt; and &lt;code&gt;:ok&lt;/code&gt; for error handling.&lt;/p&gt;

&lt;p&gt;Atoms are also very efficient, as they are internally represented by an integer and are globally unique. This means that two atoms with the same name will always refer to the same value, regardless of where they are defined or used.&lt;/p&gt;

&lt;p&gt;At first this data type may seem not useful, but in future posts you will sure see how powerful this data type is.&lt;/p&gt;

&lt;h2&gt;
  
  
  Booleans
&lt;/h2&gt;

&lt;p&gt;Booleans are a special kind of atom that can only have two possible values: &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt;. Booleans are used to represent logical conditions, such as comparisons or predicates.&lt;/p&gt;

&lt;p&gt;Booleans can be combined with logical operators, such as &lt;code&gt;and&lt;/code&gt;, &lt;code&gt;or&lt;/code&gt;, and &lt;code&gt;not&lt;/code&gt;, to form more complex expressions. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elixir"&gt;&lt;code&gt;&lt;span class="no"&gt;true&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt; &lt;span class="c1"&gt;# false&lt;/span&gt;
&lt;span class="no"&gt;true&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt; &lt;span class="c1"&gt;# true&lt;/span&gt;
&lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt; &lt;span class="c1"&gt;# false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Booleans can also be used in control flow constructs (more of this in a next post), such as &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;case&lt;/code&gt;, and &lt;code&gt;cond&lt;/code&gt;, to execute different branches of code based on some condition. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elixir"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="s2"&gt;"Positive"&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;
  &lt;span class="s2"&gt;"Negative"&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;In this article, we learned about two of the basic data types in Elixir: atoms and booleans. We saw how atoms are constants that represent names or values, and how booleans are a special kind of atom that represent logical conditions. We also saw how atoms and booleans can be used in various ways in Elixir programs.&lt;/p&gt;

&lt;p&gt;I hope this article was helpful for you. If you want to learn more about Elixir data types, you can check out these sources:&lt;/p&gt;

&lt;p&gt;Basic types - &lt;a href="https://elixir-lang.org/getting-started/basic-types.html"&gt;The Elixir programming language&lt;/a&gt;&lt;br&gt;
Typespecs and behaviours - &lt;a href="https://elixir-lang.org/getting-started/typespecs-and-behaviours.html"&gt;The Elixir programming language&lt;/a&gt;&lt;br&gt;
Elixir - &lt;a href="https://www.tutorialspoint.com/elixir/elixir_data_types.htm"&gt;Data Types&lt;/a&gt;&lt;br&gt;
Typespecs — &lt;a href="https://hexdocs.pm/elixir/1.12/typespecs.html"&gt;Elixir v1.12.3&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Thanks for reading! My goal is to make Elixir accessible and easy to understand for everyone. If you have any questions or feedback, please don't hesitate to reach out. And be sure to check back regularly for more articles on &lt;a href="https://dev.to/calbertora"&gt;https://dev.to/calbertora&lt;/a&gt;, as I strive to make each post as clear and readable as possible.&lt;/p&gt;

</description>
      <category>elixir</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Mix</title>
      <dc:creator>Carlos Ramírez</dc:creator>
      <pubDate>Tue, 25 Apr 2023 14:01:04 +0000</pubDate>
      <link>https://dev.to/calbertora/mix-3el3</link>
      <guid>https://dev.to/calbertora/mix-3el3</guid>
      <description>&lt;p&gt;This is going to be the last (I hope) post that is not focused on programming. But, for me, it's important to know all the aspects I've written before dive into the language, because all of them are important tools in a day to day writing code in Elixir.&lt;/p&gt;

&lt;p&gt;Mix is a build tool and package manager for Elixir. It is used to create, compile, and manage Elixir projects.&lt;/p&gt;

&lt;p&gt;Mix is designed to simplify the build process of Elixir applications by automating tasks such as compiling modules, managing dependencies, and generating documentation. It also provides a testing framework to help developers ensure the quality of their code. In addition, Mix comes with a powerful set of tasks and plugins that make it easy to manage project tasks like running migrations or deploying code to production.&lt;/p&gt;

&lt;p&gt;For example you can create Elixir projects with this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; mix new my_elixir_project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you need to add dependencies to your projects you have to add them to your &lt;code&gt;mix.ex&lt;/code&gt; file and then in the terminal download those dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; mix deps.get
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also run your tests to check that everything is working as expected:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; mix test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to see all the options you have you could use the help&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;  mix help
mix                   # Runs the default task (current: "mix run")
mix app.config        # Configures all registered apps
mix app.start         # Starts all registered apps
mix app.tree          # Prints the application tree
mix archive           # Lists installed archives
mix archive.build     # Archives this project into a .ez file
mix archive.install   # Installs an archive locally
mix archive.uninstall # Uninstalls archives
mix clean             # Deletes generated application files
...
...
...

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Overall, Mix is an essential tool for any Elixir developer and helps to streamline the development process.&lt;/p&gt;




&lt;p&gt;Thanks for reading! My goal is to make Elixir accessible and easy to understand for everyone. If you have any questions or feedback, please don't hesitate to reach out. And be sure to check back regularly for more articles on &lt;a href="https://dev.to/calbertora"&gt;https://dev.to/calbertora&lt;/a&gt;, as I strive to make each post as clear and readable as possible.&lt;/p&gt;

</description>
      <category>elixir</category>
      <category>beginners</category>
      <category>backend</category>
    </item>
    <item>
      <title>iex</title>
      <dc:creator>Carlos Ramírez</dc:creator>
      <pubDate>Mon, 17 Apr 2023 14:01:01 +0000</pubDate>
      <link>https://dev.to/calbertora/iex-n38</link>
      <guid>https://dev.to/calbertora/iex-n38</guid>
      <description>&lt;p&gt;Welcome back to my series on Elixir! In this post, we'll be exploring one of the most powerful tools in the Elixir developer's arsenal: iex. Short for "Interactive Elixir," iex is a command-line interface that allows you to interact with the Elixir language in real-time, making it an indispensable tool for debugging, testing, and exploring the capabilities of the language.&lt;/p&gt;

&lt;p&gt;Whether you're a seasoned Elixir developer or just getting started, iex is a tool that you'll want to have in your toolkit. In this post, we'll be taking a deep dive into what iex is, what it's used for, and how you can use it to supercharge your Elixir development workflow. So grab a cup of coffee, fire up your terminal, and let's dive in!&lt;/p&gt;

&lt;p&gt;As we &lt;a href="https://dev.to/calbertora/installing-elixir-2ga8"&gt;saw previously&lt;/a&gt;, to start iex you just need to type &lt;code&gt;iex&lt;/code&gt; in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iex
Erlang/OTP 24 [erts-12.0.4] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit]

Interactive Elixir (1.13.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, it will show you the Erlang and Elixir version you are currently using. You can easily change this using &lt;code&gt;asdf&lt;/code&gt; command as we saw previously.&lt;/p&gt;

&lt;p&gt;You can type &lt;code&gt;h&lt;/code&gt; to see the commands available in the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iex(1)&amp;gt; h

                                  IEx.Helpers

Welcome to Interactive Elixir. You are currently seeing the documentation for
the module IEx.Helpers which provides many helpers to make Elixir's shell more
joyful to work with.

This message was triggered by invoking the helper h(), usually referred to as
h/0 (since it expects 0 arguments).

You can use the h/1 function to invoke the documentation for any Elixir module
or function:

    iex&amp;gt; h(Enum)
    iex&amp;gt; h(Enum.map)
    iex&amp;gt; h(Enum.reverse/1)

You can also use the i/1 function to introspect any value you have in the
shell:

    iex&amp;gt; i("hello")

There are many other helpers available, here are some examples:

  • b/1            - prints callbacks info and docs for a given module
  • c/1            - compiles a file
  • c/2            - compiles a file and writes bytecode to the given path
...
...
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, you can also work with Elixir data types and functions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iex(2)&amp;gt; hello = :world
:world
iex(3)&amp;gt; foo = "bar"
"bar"
iex(4)&amp;gt; one = 1
1
iex(5)&amp;gt; print = fn text -&amp;gt; IO.puts text end
#Function&amp;lt;44.40011524/1 in :erl_eval.expr/5&amp;gt;
iex(6)&amp;gt; print.("Hey there")
Hey there
:ok
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see we can define variables, functions and execute those functions (we're going to deep dive into this in a later post)&lt;/p&gt;

&lt;p&gt;In this command line you can also compile Elixir files. This is super hyper mega important as you will see in my future posts how we can use &lt;code&gt;iex&lt;/code&gt; as a tool in our development process, not only for compiling Elixir files but complete applications.&lt;/p&gt;

&lt;p&gt;In conclusion iex is an interactive shell that allows you to execute Elixir code and interact with the language in real-time. This is going to be one of your best friends in your career as an Elixir Developer.&lt;/p&gt;




&lt;p&gt;Thanks for reading! My goal is to make Elixir accessible and easy to understand for everyone. If you have any questions or feedback, please don't hesitate to reach out. And be sure to check back regularly for more articles on &lt;a href="https://dev.to/calbertora"&gt;https://dev.to/calbertora&lt;/a&gt;, as I strive to make each post as clear and readable as possible.&lt;/p&gt;

</description>
      <category>iex</category>
      <category>elixir</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Installing Elixir</title>
      <dc:creator>Carlos Ramírez</dc:creator>
      <pubDate>Sun, 09 Apr 2023 00:08:57 +0000</pubDate>
      <link>https://dev.to/calbertora/installing-elixir-2ga8</link>
      <guid>https://dev.to/calbertora/installing-elixir-2ga8</guid>
      <description>&lt;p&gt;As I said previously, I want to make my posts very short and concise and this is not going to be the exception.&lt;/p&gt;

&lt;p&gt;If you're using Windows, I highly recommend install WSL so you will have the best of Linux and Windows at the same time.&lt;/p&gt;

&lt;p&gt;Having said so, the commands I show here will work for MacOS, Linux and Windows(WSL).&lt;/p&gt;

&lt;p&gt;I highly recommend installing Elixir with &lt;code&gt;asdf&lt;/code&gt; since if you are lucky enough to work with Elixir in a professional project, you might find yourself changing the version several times, so for me, this is the best option for doing it so. So this guide will show you how to do it with &lt;code&gt;asdf&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The first thing you're going to do is install Homebrew (I know, you can install it directly as &lt;a href="https://asdf-vm.com/guide/getting-started.html"&gt;the official web page&lt;/a&gt; says, but I think it's way easier using Homebrew instead)&lt;/p&gt;

&lt;p&gt;So, step 1. Install Homebrew:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/bin/bash &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember to add brew to your &lt;code&gt;.zshrc&lt;/code&gt; &lt;code&gt;.bashrc&lt;/code&gt;... file (or the one you're using).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export BREW_HOME="/home/linuxbrew/.linuxbrew/bin"
export PATH="$PATH:$BREW_HOME"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 2, install asdf:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;asdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 3, add Erlang and Elixir plugin with asdf:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf plugin-add erlang https://github.com/asdf-vm/asdf-erlang.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 4, install the latest Erlang and Elixir versions (or the one you want)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf &lt;span class="nb"&gt;install &lt;/span&gt;erlang 25.3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf &lt;span class="nb"&gt;install &lt;/span&gt;elixir 1.14.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's all, you can change locally or globally your Elixir version with a single command.&lt;/p&gt;

&lt;p&gt;Remember to add to your &lt;code&gt;.bashrc&lt;/code&gt; (or the one you're using) the shims from &lt;code&gt;asdf&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;~/.asdf/shims:&lt;span class="nv"&gt;$PATH&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can &lt;a href="https://dev.to/calbertora/iex-n38"&gt;type&lt;/a&gt; &lt;code&gt;iex&lt;/code&gt; at your terminal to make sure that everything went well:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;iex
Erlang/OTP 24 &lt;span class="o"&gt;[&lt;/span&gt;erts-12.0.4] &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;source&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;64-bit] &lt;span class="o"&gt;[&lt;/span&gt;smp:4:4] &lt;span class="o"&gt;[&lt;/span&gt;ds:4:4:10] &lt;span class="o"&gt;[&lt;/span&gt;async-threads:1] &lt;span class="o"&gt;[&lt;/span&gt;jit]

Interactive Elixir &lt;span class="o"&gt;(&lt;/span&gt;1.13.1&lt;span class="o"&gt;)&lt;/span&gt; - press Ctrl+C to &lt;span class="nb"&gt;exit&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;type &lt;/span&gt;h&lt;span class="o"&gt;()&lt;/span&gt; ENTER &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="nb"&gt;help&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
iex&lt;span class="o"&gt;(&lt;/span&gt;1&lt;span class="o"&gt;)&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: as you might see I have Elixir 1.13.1 and Erlang 24.&lt;/p&gt;

&lt;p&gt;Edit 1:&lt;br&gt;
I added the &lt;code&gt;.bashrc&lt;/code&gt; to the files to add the Homebrew variables&lt;/p&gt;

&lt;p&gt;I added the shims path.&lt;/p&gt;




&lt;p&gt;Thanks for reading! My goal is to make Elixir accessible and easy to understand for everyone. If you have any questions or feedback, please don't hesitate to reach out. And be sure to check back regularly for more articles on &lt;a href="https://dev.to/calbertora"&gt;https://dev.to/calbertora&lt;/a&gt;, as I strive to make each post as clear and readable as possible.&lt;/p&gt;

</description>
      <category>elixir</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Introduction to Elixir</title>
      <dc:creator>Carlos Ramírez</dc:creator>
      <pubDate>Sat, 01 Apr 2023 19:22:39 +0000</pubDate>
      <link>https://dev.to/calbertora/introduction-to-elixir-14pn</link>
      <guid>https://dev.to/calbertora/introduction-to-elixir-14pn</guid>
      <description>&lt;h2&gt;
  
  
  What is Elixir?
&lt;/h2&gt;

&lt;p&gt;Elixir is a dynamic, functional programming language that is designed for building scalable and fault-tolerant applications.&lt;br&gt;
It runs on the Erlang virtual machine, which provides powerful concurrency and distribution capabilities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Elixir?
&lt;/h2&gt;

&lt;p&gt;Elixir is a great choice for building applications that require high concurrency and fault tolerance, such as web applications, distributed systems, and real-time communication systems.&lt;/p&gt;

&lt;p&gt;It is also designed to be easy to learn and use, with a simple and intuitive syntax that makes it accessible to developers of all skill levels.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key features of Elixir
&lt;/h2&gt;

&lt;p&gt;Elixir has a number of key features that make it a popular choice for developers, including:&lt;/p&gt;

&lt;p&gt;Immutability: Elixir values are immutable by default, which helps to prevent bugs and makes it easier to reason about your code.&lt;/p&gt;

&lt;p&gt;Pattern matching: Elixir uses pattern matching extensively, which allows you to write concise and expressive code.&lt;/p&gt;

&lt;p&gt;Macros: Elixir has a powerful macro system that allows you to write code that generates other code, making it easy to create reusable abstractions.&lt;/p&gt;

&lt;p&gt;Concurrency and Parallelism: Elixir provides built-in support for concurrency and parallelism through its lightweight processes, which are similar to threads but have much lower memory overhead. This makes it easy to write code that can handle multiple tasks simultaneously.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting started with Elixir
&lt;/h2&gt;

&lt;p&gt;To get started with Elixir, you will need to &lt;a href="https://dev.to/calbertora/installing-elixir-2ga8"&gt;install&lt;/a&gt; the Elixir compiler and set up your development environment.&lt;/p&gt;

&lt;p&gt;Once you have done that, you can start exploring the language by writing simple programs, using online resources and tutorials to guide you.&lt;/p&gt;




&lt;p&gt;Thanks for reading! My goal is to make Elixir accessible and easy to understand for everyone. If you have any questions or feedback, please don't hesitate to reach out. And be sure to check back regularly for more articles on &lt;a href="https://dev.to/calbertora"&gt;https://dev.to/calbertora&lt;/a&gt;, as I strive to make each post as clear and readable as possible.&lt;/p&gt;

</description>
      <category>elixir</category>
      <category>introduction</category>
      <category>newbie</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
