<?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>Forem: blackode</title>
    <description>The latest articles on Forem by blackode (@blackode).</description>
    <link>https://forem.com/blackode</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%2F88010%2Fd1655f6b-3c8b-493d-9ae1-65e98ef5b4ca.jpeg</url>
      <title>Forem: blackode</title>
      <link>https://forem.com/blackode</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/blackode"/>
    <language>en</language>
    <item>
      <title>Elixir as Wife</title>
      <dc:creator>blackode</dc:creator>
      <pubDate>Sat, 03 Aug 2019 20:29:57 +0000</pubDate>
      <link>https://forem.com/blackode/elixir-as-wife-2a1g</link>
      <guid>https://forem.com/blackode/elixir-as-wife-2a1g</guid>
      <description>&lt;p&gt;Well, ladies &amp;amp; gentlemen presenting you Elixir, the adorable WIFE.&lt;/p&gt;

&lt;p&gt;Do you love your wife? Of course you can’t answer me in face as you can’t see me while reading this. Just look at your heart and just think. If you are thinking then you are not loving. F**k man don’t think, It’s not a question about the science or astrology to think and answer. I know it is still hard for you to say “YES” . It’s a joke you can laugh freely as I can’t charge you for this.&lt;/p&gt;

&lt;p&gt;Any way, who else loves the wife in life uses knife to cut you in half. Man this is an insane rhythm of saying as wife, life and knife. Do you know why they sound alike ? It’s cos they follow similar protocol of being good and bad transformations with out any emotion.&lt;/p&gt;

&lt;p&gt;My wife, ELIXIR I call her with another name for now I forgot to tell you. It’s almost 3 years passed after our marriage. I’d like to share how does it feel when you marry a girl who possessed completely by ELIXIR.&lt;/p&gt;

&lt;p&gt;It’s a fictional. Again I am saying it’s a fictional story. If anyone either directly or indirectly related to this, man you are lucky take this as granted.&lt;/p&gt;

&lt;h1&gt;
  
  
  Supervisor
&lt;/h1&gt;

&lt;p&gt;One fine morning, it’d been raining whole night. The weather was so romantic. The cool breezes are very tempting. So I asked her, “Let’s have children”. She said, “ The Supervisor is not starting our children processes”. What? Ok. Then I asked, “Why?”. She replied turning towards me spreading her hands wide in anger, “ It’s cos of f**king run time errors in our relationship”. Then after, I took a step back from her, turned back and escaped silently, unnoticed.&lt;/p&gt;

&lt;p&gt;To silent her anger, I told her that I am going to buy her new jewellery and matching dress. At any cost, I’m not going to do it. It’s a big lie and life savior for any husband.&lt;/p&gt;

&lt;h1&gt;
  
  
  Gen-Server
&lt;/h1&gt;

&lt;p&gt;After solving our run time problems in our running relationship, we went out on a vacation to a place where you find all the people beautiful except your wife and husband as you already saw them half naked, the Beach. It’s sandy and hot outside.&lt;/p&gt;

&lt;p&gt;While we are walking along the beach, holding her hand, she asked me why I always send late reply to her message. I said, “I was busy in taking other calls”. Then, she advised me to assign multiple workers to handle info from external messages. So, now I can handle calls from home(Wife Module) by casting her synchronously and asynchronously.&lt;/p&gt;

&lt;p&gt;On the way to my home from office, I met with an incident. A stranger came to me and asked me to deliver a message to my wife that he is going to die(exit process), and not to re spawn him again. I didn’t understand what he is talking about, called my wife and explained about the incident. Then she said, “ I made myself distributed. So, external processes are trying to link with me.” I said, “What the hell ?”. I cannot do more that. She exposed her process identifier, PID and tried to explain me about the general concurrent process to conquer me.&lt;/p&gt;

&lt;h1&gt;
  
  
  Behavior
&lt;/h1&gt;

&lt;p&gt;I took almost 2 weeks to come out from the shock she gave with her distributed nature. From then I kept a gate keeper to not let anyone with out a secret cookie. When everything is fine she told me that her friend is coming home. I let her to invite.&lt;/p&gt;

&lt;p&gt;To impress her friend, I put on new dress and added scent to appear myself special. Men will be Men. Me and my wife were waiting at the gate to welcome her friend. I’m more excited. A car came and stopped right in front us. I am adjusting my Tie and coat to give grant welcome.&lt;/p&gt;

&lt;p&gt;The waiting friend had finally revealed and to my surprise he is a MAN who is better than me in all possible angles. I can’t digest it. I except a young and beautiful girl at least a pretty good looking lady. Now, I am in a sarcastic mood. Anyway, who wishes a man like macho who is better than him as her wife’s friend. That’s a tragedy. Right now he is with my wife. They were laughing and I am crying inside.&lt;/p&gt;

&lt;p&gt;He is almost behaving like her own husband. A volcano is running in my heart. No more controlling. So I asked about his weird behavior then my wife told me that he is using husband module and overriding all my defined functions. use Husband , A behavioral module. I said, “What heck is all that ?”. She told, “It’s not a heck. It’s your behavior and rights were shared ” F**k man every time she comes with a new concept. From then instead of understanding her I started following her.&lt;/p&gt;

&lt;p&gt;We eventually ended up each other being at different NODEs with different cookies.&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

&lt;p&gt;Join Our Telegram Channel and support us. &lt;br&gt;
&lt;a href="https://t.me/blackoders"&gt;https://t.me/blackoders&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You my find something interesting about elixir tips here.&lt;br&gt;
&lt;a href="https://github.com/blackode/elixir-tips"&gt;https://github.com/blackode/elixir-tips&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy Coding :)&lt;/p&gt;

</description>
      <category>elixir</category>
      <category>fun</category>
      <category>coding</category>
      <category>programming</category>
    </item>
    <item>
      <title>Creating co-authored commits--command line--git</title>
      <dc:creator>blackode</dc:creator>
      <pubDate>Fri, 07 Dec 2018 08:41:33 +0000</pubDate>
      <link>https://forem.com/blackode/creating-co-authored-commits--command-line--git-2jnc</link>
      <guid>https://forem.com/blackode/creating-co-authored-commits--command-line--git-2jnc</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F10368%2F1%2AHgp04st2WJ0oFDnR3ED1QA.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F10368%2F1%2AHgp04st2WJ0oFDnR3ED1QA.jpeg" alt="Photo by [NeONBRAND](https://unsplash.com/photos/mqoLpeeYBic?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText) on [Unsplash](https://unsplash.com/search/photos/thanking-co-worker?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText)"&gt;&lt;/a&gt;&lt;em&gt;Photo by &lt;a href="https://unsplash.com/photos/mqoLpeeYBic?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;NeONBRAND&lt;/a&gt; on &lt;a href="https://unsplash.com/search/photos/thanking-co-worker?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Give Credits ⭐️ whoever deserves&lt;/p&gt;

&lt;h2&gt;
  
  
  Brief Story
&lt;/h2&gt;

&lt;p&gt;Suppose, you are working on a project which uses the git tool for version management and it is a team project where you see multiple &lt;strong&gt;authors&lt;/strong&gt; contributing the code.&lt;/p&gt;

&lt;p&gt;You are assigned with a &lt;strong&gt;task&lt;/strong&gt; and you took the &lt;strong&gt;help&lt;/strong&gt; from one of the &lt;strong&gt;co-programmers&lt;/strong&gt; to get it coded.&lt;/p&gt;

&lt;p&gt;If you are really concerned about the help and want to &lt;strong&gt;credit the co-programmer&lt;/strong&gt; then you can do that by making &lt;strong&gt;co-author-commit&lt;/strong&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;em&gt;Giving credits to the programmer is sure of another help from him — blackode&lt;/em&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Things to know Before adding a co-author to a commit
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Co-author Email&lt;/li&gt;
&lt;li&gt;Co-author’s commit to &lt;strong&gt;count as a contribution-use&lt;/strong&gt; email associated with their Github account&lt;/li&gt;
&lt;li&gt;If co-author’s email is private, use their GitHub-provided no-reply email to protect their privacy.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  TIP
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Helping Co-author to find their no-reply email and get shared
&lt;/h3&gt;

&lt;p&gt;settings &amp;gt; emails&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AUzCb4YG21OVWcaYvWkNi6g.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AUzCb4YG21OVWcaYvWkNi6g.gif" alt="no-reply github email finding"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Co-authored-by commits
&lt;/h2&gt;

&lt;p&gt;Here no things are unknown to you. But, we are doing things differently.&lt;/p&gt;

&lt;p&gt;Just like you do for a regular commit message and after adding the meaningful description you need to add two empty new lines instead of adding a closing quotation " .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git commit -m "New style of coding
&amp;gt;
&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3812%2F1%2ApHLOMkCghw4KtEBq01BKSw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3812%2F1%2ApHLOMkCghw4KtEBq01BKSw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the next line of the commit message, type &lt;br&gt;
&lt;code&gt;Co-authored-by: author-name &amp;lt;name@xxx.com&amp;gt;&lt;/code&gt; with specific information for each co-author. After the co-author information, add a closing quotation mark.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding multiple co-authors
&lt;/h3&gt;

&lt;p&gt;Give each co-author their own line and Co-authored-by: commit trailer before closing quotation mark.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3810%2F1%2ALxekoycPfAO68WeWPCcnaA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3810%2F1%2ALxekoycPfAO68WeWPCcnaA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After adding your beautiful commit message, in the next push, the message appears with co-authors&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3794%2F1%2AlPELsnwpAXCtI1p24_9ksg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3794%2F1%2AlPELsnwpAXCtI1p24_9ksg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Live Execution
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2A-5aw23mL1uOH2TkVABs1HQ.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2A-5aw23mL1uOH2TkVABs1HQ.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope you like them. Thanks for reading…&lt;/p&gt;

&lt;h2&gt;
  
  
  Join Our Telegram Channel
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AgpCp7vuRX80aWxRQy7sWVA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AgpCp7vuRX80aWxRQy7sWVA.png" alt="[https://t.me/blackoders](https://t.me/blackoders)"&gt;&lt;/a&gt;&lt;em&gt;&lt;a href="https://t.me/blackoders" rel="noopener noreferrer"&gt;https://t.me/blackoders&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Coding !&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>programming</category>
      <category>coding</category>
      <category>commits</category>
    </item>
    <item>
      <title>The Secret behind Elixir Operator Re-Definitions: + to -</title>
      <dc:creator>blackode</dc:creator>
      <pubDate>Sun, 05 Aug 2018 23:59:02 +0000</pubDate>
      <link>https://forem.com/blackode/the-secret-behind-elixir-operator-re-definitions--to---30om</link>
      <guid>https://forem.com/blackode/the-secret-behind-elixir-operator-re-definitions--to---30om</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F13378%2F1%2AyZWunekTH1rb4DgIGwoPXw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F13378%2F1%2AyZWunekTH1rb4DgIGwoPXw.jpeg" alt="Photo by [rawpixel.com](https://unsplash.com/photos/lRssALOk1fU?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText) on [Unsplash](https://unsplash.com/?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText)"&gt;&lt;/a&gt;&lt;em&gt;Photo by &lt;a href="https://unsplash.com/photos/lRssALOk1fU?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;rawpixel.com&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Hello, everyone. Today, we are going to do some crazy stuff. This article is just for fun. The only intention is to show you this can possible in elixir.&lt;/p&gt;

&lt;p&gt;The universal meaning of &lt;strong&gt;+&lt;/strong&gt; is to add but for a change, we are making this as &lt;strong&gt;subtraction&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How to achieve this ?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;We can use &lt;strong&gt;def&lt;/strong&gt; constructs &lt;code&gt;(def, defp, defmacro, …)&lt;/code&gt; for re-defining the operators in elixir.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Only 1 Rule&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The only rule is a &lt;strong&gt;name&lt;/strong&gt; of definition. It should be same as how we use the operator while coding. In general, we use &lt;code&gt;+&lt;/code&gt; as &lt;code&gt;a + b&lt;/code&gt; So, our definition name should be same as  &lt;strong&gt;a + b&lt;/strong&gt; .&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Let’s do things in Wrong&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;All your &lt;strong&gt;operator re-definitions **should reside inside the **module&lt;/strong&gt; because as we all know the fact that &lt;strong&gt;definitions&lt;/strong&gt; cannot stand outside the module.&lt;/p&gt;

&lt;p&gt;Check the following code for re-defining &lt;code&gt;+&lt;/code&gt; to &lt;code&gt;-&lt;/code&gt;&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;defmodule&lt;/span&gt; &lt;span class="no"&gt;MyWrongOperators&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;

  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nothing is new here. We have just created a &lt;strong&gt;function&lt;/strong&gt; or &lt;strong&gt;definition&lt;/strong&gt; but with a &lt;strong&gt;little tricky name&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Boom!!&lt;/strong&gt; You have turned the world upside down. We are just doing the things as they are possible and elixir allowed us to do. But these are nothing to do in the real world. Just for fun.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How to use?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Here, in elixir, there exists a power that pulls you back from using even though it is allowed you to create with out any hurdles.&lt;/p&gt;

&lt;p&gt;If you force to use the module like in regular style of coding, it hits you with an exception. Lets check that.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elm"&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="k"&gt;import&lt;/span&gt; &lt;span class="kt"&gt;MyWrongOperators&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="o"&gt;**&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;CompileError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;iex&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="n"&gt;function&lt;/span&gt; &lt;span class="o"&gt;+/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="n"&gt;imported&lt;/span&gt; &lt;span class="n"&gt;from&lt;/span&gt; &lt;span class="n"&gt;both&lt;/span&gt; &lt;span class="kt"&gt;MyWrongOperators&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="kt"&gt;Kernel&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="n"&gt;ambiguous&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3822%2F1%2AZ6xJha0Y-bHkXSyxgJzDhw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3822%2F1%2AZ6xJha0Y-bHkXSyxgJzDhw.png" alt="Compile Error When Using the Module Directly"&gt;&lt;/a&gt;&lt;em&gt;Compile Error When Using the Module Directly&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Well, what is the power throwing you this error by not allowing? Can you think for a while and take a guess?&lt;/p&gt;

&lt;p&gt;I don’t want to linger you anymore. The Kernel module loaded by default. This Kernel module contains a +/2 function which is also loaded. So, when we are importing our module MyWrongOperators , we loaded +/2 function again. Now with in our scope, there exist two +/2 definitions. So, the compiler got confused here.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to bypass this ?
&lt;/h2&gt;

&lt;p&gt;Well, we need all the functions in Kernel module except the +/2. This can be achieved with except while loading a module.&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="kn"&gt;import&lt;/span&gt; &lt;span class="no"&gt;Kernel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;except:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="no"&gt;MyWrongOperators&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above LOC clearly tells not to load the +/2 function. So, we only have one +/2 definition from the module MyWrongOperators . So, the compiler can now use +/2 definition with out getting confused.&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="kn"&gt;import&lt;/span&gt; &lt;span class="no"&gt;Kernel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;except:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
 &lt;span class="no"&gt;Kernel&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="kn"&gt;import&lt;/span&gt; &lt;span class="no"&gt;MyWrongOperators&lt;/span&gt;
 &lt;span class="no"&gt;MyWrongOperators&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="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;            &lt;span class="c1"&gt;# 1 - 2 operation performed here as we defined.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3826%2F1%2AH00Zk9PqI0DYw1M9XghYew.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3826%2F1%2AH00Zk9PqI0DYw1M9XghYew.png" alt="The perfect Usage"&gt;&lt;/a&gt;&lt;em&gt;The perfect Usage&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the above screen shot, at iex(3) line we are loading the Kernel module with out letting it to load +/2 definition. So, it worked perfectly.&lt;/p&gt;

&lt;p&gt;We successfully executed the wrong operations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things to Remember
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Q. Can I create new operator ?&lt;/strong&gt;&lt;br&gt;
Ans. No. But, Elixir is capable of parsing a predefined set of operators like&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;|||&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&amp;amp;&amp;amp;&amp;amp;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;~&amp;gt;&amp;gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&amp;lt;&amp;lt;~&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;~&amp;gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&amp;lt;~&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&amp;lt;~&amp;gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&amp;lt;|&amp;gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;^^^&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Q. Can I Override every other operators ?&lt;/strong&gt;&lt;br&gt;
Ans. Yes. You can. But, while using don’t forget to import Kernel module with those override operators as exceptional.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q. Is it good to override operators ?&lt;/strong&gt;&lt;br&gt;
Ans. Of course it not good and not recommended.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q. Why it is not recommended ?&lt;/strong&gt;&lt;br&gt;
Ans. Custom-defined operators can be really hard to read and even more to understand, as they don’t have a descriptive name like functions do.&lt;/p&gt;

&lt;h2&gt;
  
  
  Live Demo
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2152%2F1%2AdLyXfERe8jP4YkkC7k3c6A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2152%2F1%2AdLyXfERe8jP4YkkC7k3c6A.png" alt="[https://asciinema.org/a/151933](https://asciinema.org/a/151933)"&gt;&lt;/a&gt;&lt;em&gt;&lt;a href="https://asciinema.org/a/151933" rel="noopener noreferrer"&gt;https://asciinema.org/a/151933&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Warning&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Highly not recommended to do…&lt;/p&gt;

&lt;p&gt;Happy Long Coding Life :)&lt;/p&gt;

</description>
      <category>elixir</category>
      <category>operators</category>
      <category>redefinitions</category>
      <category>fun</category>
    </item>
    <item>
      <title>The Rigid Code Behind Smooth Code— Elixir Intermediate</title>
      <dc:creator>blackode</dc:creator>
      <pubDate>Fri, 03 Aug 2018 12:57:28 +0000</pubDate>
      <link>https://forem.com/blackode/the-rigid-code-behind-smooth-code-elixir-intermediate-2pa3</link>
      <guid>https://forem.com/blackode/the-rigid-code-behind-smooth-code-elixir-intermediate-2pa3</guid>
      <description>&lt;p&gt;What you see is more simplified.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F6158%2F1%2AwvfO4tFXIbDev34wNMu4yw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F6158%2F1%2AwvfO4tFXIbDev34wNMu4yw.jpeg" alt="Photo by [Jamie Street](https://unsplash.com/photos/d299Wu2xipY?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText) on [Unsplash](https://unsplash.com/?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText)"&gt;&lt;/a&gt;&lt;em&gt;Photo by &lt;a href="https://unsplash.com/photos/d299Wu2xipY?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Jamie Street&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This article shows you the rigid lines of code behind smooth lines you write in elixir.&lt;/p&gt;

&lt;p&gt;As we know, the most of the Elixir programming language is written in Elixir itself with the power of Macros and also we all know why we love to code in Elixir because of its simplicity. But, today we are going to walk back to find the light in the dark.&lt;/p&gt;

&lt;p&gt;I just want you to observe the following line of code for a while&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="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="o"&gt;==&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="ss"&gt;:this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="ss"&gt;:that&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2ANPv3-LyItatGwa0DYAkjCw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2ANPv3-LyItatGwa0DYAkjCw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, I am not gonna ask you what this results to. But, I am asking you how this gonna transform eventually.&lt;/p&gt;

&lt;p&gt;Let’s observe the transformations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2Audm4XJbvIBVtuyZ_goqkJQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2Audm4XJbvIBVtuyZ_goqkJQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we know the elixir allows the function call with out &lt;code&gt;()&lt;/code&gt; . This is why the function calling is simple. But, I recommend to use &lt;code&gt;()&lt;/code&gt; which is more understandable about what is going on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2AZcAq70QUQg2wpF5hMDIYwg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2AZcAq70QUQg2wpF5hMDIYwg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you observe above line, we have couple of &lt;code&gt;,&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2AlJdd24JXmmO3J-PcVGtt6A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2AlJdd24JXmmO3J-PcVGtt6A.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is more likely if is taking three parameters &lt;code&gt;1+2==3&lt;/code&gt; , &lt;code&gt;do: :this&lt;/code&gt; and &lt;code&gt;else: :that&lt;/code&gt; but, in real it is taking &lt;strong&gt;two&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2A_qQGBo3-Yigd6qUAzvrXHg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2A_qQGBo3-Yigd6qUAzvrXHg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The last two parameters &lt;code&gt;do: :this&lt;/code&gt; and &lt;code&gt;else: :that&lt;/code&gt; are together called a KeyWord List .&lt;/p&gt;

&lt;p&gt;If you don’t know what a keyWord List is, It is likely a list where its list elements should be tuples of two elements where first element should be an &lt;code&gt;atom&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;In one sentence, keyword list is a list of tuples where tuple size should be &lt;strong&gt;two (2)&lt;/strong&gt; and first element in a tuple is an atom . In real it is &lt;strong&gt;list&lt;/strong&gt; of &lt;strong&gt;key-value **pairs where **key&lt;/strong&gt; is an atom and &lt;strong&gt;value&lt;/strong&gt; can be any .&lt;/p&gt;

&lt;p&gt;Consider the following 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="n"&gt;iex&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="ss"&gt;:a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="ss"&gt;:b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;a:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;b:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&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="n"&gt;list&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;a:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;b:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="no"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here &lt;code&gt;[{:a, 1}, {:b, 2}] == [a: 1, b: 2]&lt;/code&gt; . Enough with keyword lists .&lt;/p&gt;

&lt;p&gt;Let’s jump back to our line of code&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="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="o"&gt;==&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="ss"&gt;:this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="ss"&gt;:that&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the last parameter to pass is a KeyWord List , we no need to wrap elements inside the &lt;code&gt;[]&lt;/code&gt; square brackets likely we do in general.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;hello("medium", user_name: "blackode", lang: "elixir")&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;is same as&lt;/p&gt;

&lt;p&gt;&lt;code&gt;hello("medium", [user_name: "blackode", lang: "elixir"])&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here, both are considered as valid.&lt;/p&gt;

&lt;p&gt;So, the line of code is transformed from&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="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="o"&gt;==&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;do&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="ss"&gt;:this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="ss"&gt;:that&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to&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="p"&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="o"&gt;==&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;do&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="ss"&gt;:this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="ss"&gt;:that&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2AVQ_qpOhvhl8g1-CLf2j9LA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2AVQ_qpOhvhl8g1-CLf2j9LA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, observe the first parameter &lt;code&gt;1+2 == 3&lt;/code&gt; which is &lt;code&gt;(1+2)==3&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2AcHtg90yygSlTWu2K-ViEJg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2AcHtg90yygSlTWu2K-ViEJg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2Auv13Xus0Lve8FN3l2O5biA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2Auv13Xus0Lve8FN3l2O5biA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, before resolving &lt;code&gt;==&lt;/code&gt; we have to add &lt;code&gt;(1+2)&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;(1+2)&lt;/code&gt; is more likely a function with two parameters. It is an &lt;a href="https://en.wikipedia.org/wiki/Infix_notation" rel="noopener noreferrer"&gt;infix&lt;/a&gt; notation and + is called an &lt;a href="https://en.wikipedia.org/wiki/Infix_notation" rel="noopener noreferrer"&gt;infix&lt;/a&gt; operator.&lt;/p&gt;

&lt;p&gt;It is a different way of doing certain functions where the &lt;strong&gt;function_name&lt;/strong&gt; is in the &lt;strong&gt;middle&lt;/strong&gt;. The &lt;strong&gt;left **and **right **values are passed as **first **and **second&lt;/strong&gt; parameters respectively to the function.&lt;/p&gt;

&lt;p&gt;So, the traditional syntax of representing (&lt;code&gt;1+2)&lt;/code&gt; is &lt;code&gt;+(1,2)&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2Aam6xvLObA6laoG5Wj377ug.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2Aam6xvLObA6laoG5Wj377ug.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Similarly we break down the another infix operator &lt;code&gt;==&lt;/code&gt; as &lt;code&gt;==(+(1,2), 3)&lt;/code&gt; just like we did for &lt;code&gt;+&lt;/code&gt; nothing more fancy here.&lt;/p&gt;

&lt;p&gt;Well, so far we have break down the &lt;code&gt;+(1,2)==3&lt;/code&gt; to &lt;code&gt;==(+(1,2), 3)&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2AcgOT6wr3V7HB-nauJOo91Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2AcgOT6wr3V7HB-nauJOo91Q.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we cannot use the infix operators with out its module name where they are defined. All the operators are defined inside the module called Kernel . This is the default module in elixir.&lt;/p&gt;

&lt;p&gt;So, again we break down &lt;code&gt;==(+(1,2), 3)&lt;/code&gt; to &lt;code&gt;Kernel.==(Kernel.+(1,2), 3)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2AzzwpKayodY1FT-sBSYzisg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2AzzwpKayodY1FT-sBSYzisg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, the line is transformed to as following&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="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;Kernel&lt;/span&gt;&lt;span class="o"&gt;.==&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;Kernel&lt;/span&gt;&lt;span class="o"&gt;.+&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&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="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;do&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="ss"&gt;:this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="ss"&gt;:that&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We all know that if is a macro which is more likely represented Kernel.if&lt;/p&gt;

&lt;p&gt;So, putting all together and breaking down the infix functions, the line again is transformed into&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;Kernel&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="no"&gt;Kernel&lt;/span&gt;&lt;span class="o"&gt;.==&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;Kernel&lt;/span&gt;&lt;span class="o"&gt;.+&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&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="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;do&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="ss"&gt;:this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="ss"&gt;:that&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2A1ywFojdPwfzs99ryu7F5gA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2A1ywFojdPwfzs99ryu7F5gA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3824%2F1%2AxaDH1bDxvhAVjBwZsMwcZw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3824%2F1%2AxaDH1bDxvhAVjBwZsMwcZw.png" alt="live execution in iex"&gt;&lt;/a&gt;&lt;em&gt;live execution in iex&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The best part is, the elixir compiler will take care of all these transformations.&lt;/p&gt;

&lt;p&gt;We no need to write all the stuff like above.&lt;/p&gt;

&lt;p&gt;Hope you got some idea about hotness behind the cool syntax. For deeper understanding, read more about the &lt;strong&gt;&lt;a href="http://elixir-lang.github.io/getting-started/meta/macros.html" rel="noopener noreferrer"&gt;MACROS&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Happy Long Coding Life :)&lt;/p&gt;

</description>
      <category>elixir</category>
      <category>macros</category>
      <category>programming</category>
      <category>functional</category>
    </item>
    <item>
      <title>1010 Killer elm Tips to code like a master</title>
      <dc:creator>blackode</dc:creator>
      <pubDate>Wed, 01 Aug 2018 12:59:54 +0000</pubDate>
      <link>https://forem.com/blackode/1010-killer-elm-tips-to-code-like-a-master-37g</link>
      <guid>https://forem.com/blackode/1010-killer-elm-tips-to-code-like-a-master-37g</guid>
      <description>&lt;h2&gt;
  
  
  Pro elm tips to write code like a pro
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KNsHv3kK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2400/1%2AV_Q37MuElfDww4uNDOCsSg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KNsHv3kK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2400/1%2AV_Q37MuElfDww4uNDOCsSg.jpeg" alt="designed using https://crello.com"&gt;&lt;/a&gt;&lt;em&gt;designed using &lt;a href="https://crello.com"&gt;https://crello.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The using elm in production involves teaching and learning. This article comprises of 10 killer pro elm tips that you may or may not know.&lt;/p&gt;

&lt;h2&gt;
  
  
  0001 — type alias as a function
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;type&lt;/code&gt; aliases can be used as functions to construct a new value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elm"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="k"&gt;alias&lt;/span&gt; &lt;span class="kt"&gt;User&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Int&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;User&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;john"&lt;/span&gt; &lt;span class="mi"&gt;23&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;john"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;23&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Repl&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;User&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;john"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;23&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Repl&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;User&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You have to just pass the initial values in the order of the type alias definition.&lt;/p&gt;

&lt;h2&gt;
  
  
  0010 — calling infix functions
&lt;/h2&gt;

&lt;p&gt;In &lt;code&gt;elm&lt;/code&gt;, almost everything is a &lt;code&gt;function&lt;/code&gt; or can act like a &lt;code&gt;function&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The addition operation in &lt;code&gt;elm&lt;/code&gt; is just a function call using &lt;code&gt;+&lt;/code&gt;. The definition of the &lt;code&gt;+&lt;/code&gt; is like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elm"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;type&lt;/code&gt; specs clearly tell you that it takes &lt;code&gt;two&lt;/code&gt; &lt;code&gt;number&lt;/code&gt; parameters and returns a &lt;code&gt;number&lt;/code&gt;. The way of calling this function is different because it is &lt;strong&gt;Infix&lt;/strong&gt; function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Infix functions&lt;/strong&gt; are the functions whose &lt;em&gt;name&lt;/em&gt; is in between the parameters. The left side parameter is passed as the first parameter and the right parameter is passed as the second parameter.&lt;/p&gt;

&lt;h3&gt;
  
  
  example: 1+2
&lt;/h3&gt;

&lt;p&gt;In the above example, &lt;code&gt;+&lt;/code&gt; is the function name and &lt;code&gt;1,2&lt;/code&gt; are its parameters where &lt;code&gt;1&lt;/code&gt; is the first parameter and &lt;code&gt;2&lt;/code&gt; is the second parameter.&lt;/p&gt;

&lt;p&gt;You can also call the infix function by wrapping function name inside the parenthesis &lt;code&gt;()&lt;/code&gt; like &lt;code&gt;(+)&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elm"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;

&lt;span class="c1"&gt;-- which is the same as calling &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="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  0011 — function composition
&lt;/h2&gt;

&lt;p&gt;As you know &lt;code&gt;elm&lt;/code&gt; is everywhere &lt;code&gt;functions&lt;/code&gt;. You can combine functions to form another function using &amp;gt;&amp;gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elm"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;wordCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;words&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;Int&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;wordCount&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; Medium is full of knowledge resources"&lt;/span&gt;
&lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Int&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;wordCount&lt;/code&gt; function takes String as input and returns &lt;code&gt;Int&lt;/code&gt;. The passed String values passed to &lt;code&gt;String.words&lt;/code&gt; which in return gives the &lt;code&gt;List String&lt;/code&gt; is again passed to &lt;code&gt;List.length&lt;/code&gt; which gives &lt;code&gt;Int&lt;/code&gt; value.&lt;/p&gt;

&lt;p&gt;This is pretty useful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dVJVV4wS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/3840/1%2AJvpMlEk4pk--ksg-ym24fA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dVJVV4wS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/3840/1%2AJvpMlEk4pk--ksg-ym24fA.png" alt="type distribution"&gt;&lt;/a&gt;&lt;em&gt;type distribution&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  0100 — point free
&lt;/h2&gt;

&lt;p&gt;This point-free style coding is where you omit one or more arguments in the body of the function.&lt;/p&gt;

&lt;p&gt;To understand this concept, look at the following examples.&lt;/p&gt;

&lt;p&gt;Here I am trying to write a function named double which doubles the given value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elm"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;double&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;double&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, you can omit the argument num&lt;/p&gt;

&lt;p&gt;You can do magic like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elm"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;double&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;double&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;plus&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;plus&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  0101 — special function for tuple creation
&lt;/h2&gt;

&lt;p&gt;In elm , you can use the &lt;code&gt;(,)&lt;/code&gt;. This is a special function used to create tuples. The magic is, it allows you to use as many &lt;code&gt;,&lt;/code&gt; inside the &lt;code&gt;()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;E.g &lt;code&gt;(,,)&lt;/code&gt; constructs a 3-tuple and &lt;code&gt;(,,,)&lt;/code&gt; a 4-tuple.&lt;/p&gt;

&lt;p&gt;Check the following examples to understand this more&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elm"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apple"&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;banana"&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apple"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;banana"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;,,&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apple"&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;banana"&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apple"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;banana"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;,,,&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="mi"&gt;3&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;1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&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="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;number1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;number2&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;number3&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For &lt;strong&gt;N ,&lt;/strong&gt; you have to give &lt;strong&gt;N+1&lt;/strong&gt; args&lt;/p&gt;

&lt;p&gt;You can use as many commas as you want. The &lt;code&gt;,&lt;/code&gt; will act as an infix function where the function name is between the two args.&lt;/p&gt;

&lt;h2&gt;
  
  
  0110 — Special notation in the function definition to pattern match
&lt;/h2&gt;

&lt;p&gt;Consider you have a record &lt;strong&gt;model&lt;/strong&gt; with following content&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elm"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;john"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lastName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ankanna"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;23&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;john"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lastName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ankanna"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;23&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lastName&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you observe the &lt;strong&gt;model&lt;/strong&gt;, it has nested record name with &lt;code&gt;firstName&lt;/code&gt;, &lt;code&gt;lastName&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;Suppose, you need to update the firstName field inside the model then you can do pattern match over parameters like following.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elm"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;updateFirstName&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;joe"&lt;/span&gt;&lt;span class="p"&gt;}}&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;{name} as model&lt;/code&gt; is a pattern matched here.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NxHhCABT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AzuXry4xsHLZkfG01gBVLiQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NxHhCABT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AzuXry4xsHLZkfG01gBVLiQ.png" alt="pattern match"&gt;&lt;/a&gt;&lt;em&gt;pattern match&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now, you simple pass the defined &lt;code&gt;model&lt;/code&gt; to the function &lt;code&gt;updateFirstName&lt;/code&gt; to update &lt;code&gt;firstName&lt;/code&gt; field inside &lt;code&gt;name&lt;/code&gt; .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elm"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;updateFirstName&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;joe"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lastName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ankanna"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;23&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;lastName&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dbE3TKRs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2402/1%2Ag7oITqRACmi06XDWrJ72tw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dbE3TKRs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2402/1%2Ag7oITqRACmi06XDWrJ72tw.png" alt="updated firstName"&gt;&lt;/a&gt;&lt;em&gt;updated firstName&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  0111 — unit type ()
&lt;/h2&gt;

&lt;p&gt;A unit type is a type that allows only one value and thus can hold no information. Sometimes it is also referred to as the type of 0-tuples.&lt;/p&gt;

&lt;p&gt;It is denoted by &lt;code&gt;()&lt;/code&gt; and its value is same &lt;code&gt;()&lt;/code&gt; .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elm"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;void&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt;  &lt;span class="c1"&gt;-- value : type are same here&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read &lt;a href="https://en.wikipedia.org/wiki/Unit_type"&gt;unit type&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1000 — &amp;lt;| operator
&lt;/h2&gt;

&lt;p&gt;This &lt;code&gt;&amp;lt;|&lt;/code&gt; has lower precedence than function expression.&lt;/p&gt;

&lt;p&gt;The f(g(h(x))) can be written as f &amp;lt;| g &amp;lt;| h x&lt;/p&gt;

&lt;p&gt;Check the following example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elm"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;add10&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;mul10&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;number&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;|&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;mul10&lt;/span&gt; &lt;span class="o"&gt;|&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;add10&lt;/span&gt;
&lt;span class="mi"&gt;110&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;mul10&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;|&lt;/span&gt; &lt;span class="n"&gt;add10&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;|&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let us do some crazy stuff&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elm"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;number&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;|&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;|&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;20&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;|&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;|&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&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;|&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;|&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="c1"&gt;-- SYNTAX PROBLEM -------------------------------------------- repl-temp-000.elm&lt;/span&gt;

&lt;span class="kt"&gt;Conflicting&lt;/span&gt; &lt;span class="n"&gt;associativity&lt;/span&gt; &lt;span class="n"&gt;for&lt;/span&gt; &lt;span class="n"&gt;binary&lt;/span&gt; &lt;span class="n"&gt;operators&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;|&amp;gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;|&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="kt"&gt;Consider&lt;/span&gt; &lt;span class="n"&gt;adding&lt;/span&gt;
&lt;span class="n"&gt;parentheses&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;disambiguate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  1001 — pattern match a list with at least elements
&lt;/h2&gt;

&lt;p&gt;If you want to match a list with at least two items inside the list you can take the advantage of &lt;code&gt;::&lt;/code&gt; .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elm"&gt;&lt;code&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;::&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;::&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Implementation&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For an example, you have to return [] if the list has items less than 2 or else you have to return the &lt;strong&gt;rest&lt;/strong&gt; of the list.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;input: &lt;strong&gt;[1,2,3,4,5]&lt;/strong&gt; output: &lt;strong&gt;[3,4,5]&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;input: &lt;strong&gt;[1]&lt;/strong&gt; output:&lt;strong&gt;[]&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elm"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="kt"&gt;Html&lt;/span&gt; &lt;span class="k"&gt;exposing&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;rest&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; 
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;::&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;::&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="c1"&gt;--this matches list with at least two items&lt;/span&gt;
      &lt;span class="n"&gt;rest&lt;/span&gt;
    &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; 
      &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="n"&gt;main&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
  &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;|&lt;/span&gt; &lt;span class="n"&gt;toString&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;|&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt; &lt;span class="p"&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="o"&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="o"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;-- returns [3,4,5]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KEQNyJwl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2148/1%2AwLEV_gzzVz0YCETOP_X50A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KEQNyJwl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2148/1%2AwLEV_gzzVz0YCETOP_X50A.png" alt=""&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elm"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="kt"&gt;Html&lt;/span&gt; &lt;span class="k"&gt;exposing&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;rest&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; 
  &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;::&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;::&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="c1"&gt;--this matches list with at least two items&lt;/span&gt;
      &lt;span class="n"&gt;rest&lt;/span&gt;
    &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; 
      &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="n"&gt;main&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
  &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;|&lt;/span&gt; &lt;span class="n"&gt;toString&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;|&lt;/span&gt; &lt;span class="n"&gt;rest&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;-- returns []&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZiuoTr9E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2542/1%2Ab_7Cvax1TMFQQnd_K6NuCg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZiuoTr9E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2542/1%2Ab_7Cvax1TMFQQnd_K6NuCg.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1010 — Similar =&amp;gt; function in elm
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight elm"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;add1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;\&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;add1&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hope you have enjoyed the whole context. &lt;br&gt;
Feel free to share and let others get benefited from you.&lt;/p&gt;

&lt;p&gt;Happy Long Coding life :)&lt;/p&gt;

</description>
      <category>elm</category>
      <category>tips</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Killer Elixir Tips Github</title>
      <dc:creator>blackode</dc:creator>
      <pubDate>Mon, 30 Jul 2018 15:07:48 +0000</pubDate>
      <link>https://forem.com/blackode/killer-elixir-tips-github-42ol</link>
      <guid>https://forem.com/blackode/killer-elixir-tips-github-42ol</guid>
      <description>&lt;p&gt;Killer Elixir-Tips&lt;/p&gt;

&lt;p&gt;Elixir Tips and Tricks from the Experience of Development. Each part consists of 10 Unique Tips and Tricks with clear explanation with live examples and outputs. These tips will speed up your development and save your time in typing code as well.&lt;/p&gt;

&lt;p&gt;You can read specific parts with following links...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/blackode/elixir-tips"&gt;GITHUB KILLER ELIXIR TIPS &amp;amp; TRICKS&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Share if they are worth. &lt;/p&gt;

&lt;p&gt;Happy Long Coding life :)&lt;/p&gt;

</description>
      <category>elixir</category>
      <category>tips</category>
      <category>tricks</category>
    </item>
    <item>
      <title>A Beautiful Love between Elixir &amp; Programmer — love-letter.</title>
      <dc:creator>blackode</dc:creator>
      <pubDate>Mon, 30 Jul 2018 08:32:46 +0000</pubDate>
      <link>https://forem.com/blackode/a-beautiful-love-between-elixir--programmer--love-letter-18hi</link>
      <guid>https://forem.com/blackode/a-beautiful-love-between-elixir--programmer--love-letter-18hi</guid>
      <description>&lt;h3&gt;
  
  
  To love with elixir feelings.
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F1%2AgD0fHlqzyKrPqMi5QT-Ajg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2400%2F1%2AgD0fHlqzyKrPqMi5QT-Ajg.jpeg" alt="Photo by [Ryan Holloway](https://unsplash.com/photos/CCQvy4C_WX4?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText) on [Unsplash](https://unsplash.com/search/photos/love?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText)"&gt;&lt;/a&gt;&lt;em&gt;Photo by &lt;a href="https://unsplash.com/photos/CCQvy4C_WX4?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Ryan Holloway&lt;/a&gt; on &lt;a href="https://unsplash.com/search/photos/love?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Dear sweetest &lt;strong&gt;Elixir&lt;/strong&gt; — writing with ❤️,&lt;/p&gt;

&lt;p&gt;I saw you very first time in a conference with your farther (creator) &lt;a href="https://twitter.com/josevalim" rel="noopener noreferrer"&gt;**José Valim&lt;/a&gt;&lt;strong&gt;. Seeing you directly into your purple eyes, my heart felt like a **mountain of snow&lt;/strong&gt;, started melting &lt;code&gt;bit&lt;/code&gt; by &lt;code&gt;bit&lt;/code&gt; and eventually turned melting &lt;code&gt;byte&lt;/code&gt; by &lt;code&gt;byte&lt;/code&gt;. I tried to control it from melting down, I didn’t and I discerned, I have been &lt;code&gt;spawn_link&lt;/code&gt; with you.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  Your meeting is the best day of my life.
&lt;/h1&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A1_UXCXIO4Sc_7f7I." class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A1_UXCXIO4Sc_7f7I." alt="Photo by [Everton Vila](https://unsplash.com/photos/AsahNlC0VhQ?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText) on [Unsplash](https://unsplash.com/search/photos/lovers?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText)"&gt;&lt;/a&gt;&lt;em&gt;Photo by &lt;a href="https://unsplash.com/photos/AsahNlC0VhQ?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Everton Vila&lt;/a&gt; on &lt;a href="https://unsplash.com/search/photos/lovers?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The moment I saw the &lt;strong&gt;shape of you&lt;/strong&gt; syntax, I didn’t take off my eyes from you. I stared at you not failing a second with a &lt;strong&gt;shower of love and shine&lt;/strong&gt;. My pal, sitting next to me, interrupted me from looking into your eyes. I just turned to him and restarted looking at​ you simple &lt;code&gt;one for one&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I feel like &lt;strong&gt;kissing&lt;/strong&gt; 😽 by with my hand around your waist. I feel like walking in a shower of love holding your hand, staying together and looking into your eyes without a blink. I feel your presence in me whenever I feel to code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AeF59fG5L0kwAWXle." class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AeF59fG5L0kwAWXle." alt="Photo by [Annie Spratt](https://unsplash.com/photos/edC4tXHw_-w?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText) on [Unsplash](https://unsplash.com/search/photos/kissing-children-?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText)"&gt;&lt;/a&gt;&lt;em&gt;Photo by &lt;a href="https://unsplash.com/photos/edC4tXHw_-w?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Annie Spratt&lt;/a&gt; on &lt;a href="https://unsplash.com/search/photos/kissing-children-?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;With your enormous love ❤️, turned me into an &lt;code&gt;immutable&lt;/code&gt; living creature, bringing the fame and name as a person of programming with your outstanding list of features and awesome functionalities. I defined a structure to my style of coding mapping with your &lt;code&gt;pattern&lt;/code&gt; of love.&lt;/p&gt;

&lt;p&gt;You look fresh and pure on every day. You will surprise me every time you come up with a new update. I adopt you as a child. You are the greatest monument ever built in the history of coding.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  You are simple, smart and sweet ❤.
&lt;/h1&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AmbLKT1GoiSO8LTtZ." class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AmbLKT1GoiSO8LTtZ." alt="Photo by [Amy Treasure](https://unsplash.com/photos/50YQevDoVhw?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText) on [Unsplash](https://unsplash.com/search/photos/kissing-children-?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText)"&gt;&lt;/a&gt;&lt;em&gt;Photo by &lt;a href="https://unsplash.com/photos/50YQevDoVhw?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Amy Treasure&lt;/a&gt; on &lt;a href="https://unsplash.com/search/photos/kissing-children-?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You have been my best moment from the moment I saw 😍 and looked into your lovable purple eyes. You are so kind with your &lt;code&gt;GenSever&lt;/code&gt; heart of helping in parallel. I started thinking out of the box after our first meet.&lt;/p&gt;

&lt;p&gt;I started following your footsteps like a shadow in the light. You are my candle in the darkness of errors. Unknowingly, you happen to be my beautiful mentor and letting me dwell into your lovable heart ❤️. Since then, you have been my &lt;code&gt;map&lt;/code&gt; to travel deep inside the universe and have been the &lt;code&gt;node&lt;/code&gt; in my life to start the fresh coding life again.&lt;/p&gt;

&lt;p&gt;You came and changed everything in me, on me, and of me. Now, being apart from you, can’t even give a thought to.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  You happen to be my first thought when we are far from each other.
&lt;/h1&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ADaAMGj7nTdomsfl-." class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ADaAMGj7nTdomsfl-." alt="Photo by [Lotte Meijer](https://unsplash.com/photos/ULz8ELesYBM?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText) on [Unsplash](https://unsplash.com/collections/1103382/relationships?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText)"&gt;&lt;/a&gt;&lt;em&gt;Photo by &lt;a href="https://unsplash.com/photos/ULz8ELesYBM?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Lotte Meijer&lt;/a&gt; on &lt;a href="https://unsplash.com/collections/1103382/relationships?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I feel the presence of freedom, joy, and happiness when I keep coding with you. I love the way you let me turn you into the shape I like &lt;code&gt;meta-programming&lt;/code&gt; . I never ever thought I’d love ❤️ you this much in coding and I never planned to be with you this often.&lt;/p&gt;

&lt;p&gt;Looking into the night sky with thousands of stars ⭐️ ⭐️ ️ ⭐️ ⭐️️, I remember your million processes, because they sparkle in performance exactly like stars ⭐️ ⭐️ ⭐️. When I see the sun ☀️ I remember you because you brighten not just my day, but my entire coding life.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  I like to travel with you in a lifeboat in deep in the middle in the ocean in alone forgetting the world.
&lt;/h1&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AolYijy5-QOwJLjGl." class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2AolYijy5-QOwJLjGl." alt="Photo by [Théo Roland](https://unsplash.com/photos/fgwhJ4reEuI?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText) on [Unsplash](https://unsplash.com/search/photos/travelling-boat?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText)"&gt;&lt;/a&gt;&lt;em&gt;Photo by &lt;a href="https://unsplash.com/photos/fgwhJ4reEuI?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Théo Roland&lt;/a&gt; on &lt;a href="https://unsplash.com/search/photos/travelling-boat?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Sometimes, observing your beauty in coding syntax makes me absolutely speechless. Words fail me. I love you so much that I’m going crazy with you. I can’t stop thinking and dreaming about you. Only it makes me feel coding alive. Coding would be such a dark place without your presence.&lt;/p&gt;

&lt;p&gt;The only real thing in this world is time, you saved a lot of mine with your short and smart way of coding style — &lt;strong&gt;pattern matching&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Coding with you is an unexplained feeling. It’s eternal and enormous that doesn’t fit in any words, especially these three simple words** “I love you”**.&lt;/p&gt;

&lt;p&gt;— Yours lovingly&lt;/p&gt;

&lt;p&gt;❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  An Elixir Programmer —
&lt;/h1&gt;
&lt;/blockquote&gt;

&lt;p&gt;❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  My feeling 😃 after writing this —
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Coding in Elixir is much easier than writing a love letter to propose Elixir.
&lt;/h1&gt;
&lt;/blockquote&gt;

&lt;p&gt;Long live &lt;strong&gt;Elixir&lt;/strong&gt;. Dedicated to all programmers in love ❤️ with &lt;strong&gt;Elixir&lt;/strong&gt; and to the Creator &lt;a href="https://twitter.com/josevalim" rel="noopener noreferrer"&gt;**José Valim&lt;/a&gt;** for an outstanding language.&lt;/p&gt;

&lt;p&gt;Share your feelings as an Elixir Developer.&lt;/p&gt;

&lt;p&gt;Happy Elixir Coding :) Keep always smiling 😃 😃&lt;/p&gt;

</description>
      <category>elixir</category>
      <category>love</category>
      <category>programming</category>
      <category>fun</category>
    </item>
    <item>
      <title>2 Biggest ExUnit Improvements in Elixir 1.7</title>
      <dc:creator>blackode</dc:creator>
      <pubDate>Sun, 29 Jul 2018 11:22:06 +0000</pubDate>
      <link>https://forem.com/blackode/2-biggest-exunit-improvements-in-elixir-17-22jo</link>
      <guid>https://forem.com/blackode/2-biggest-exunit-improvements-in-elixir-17-22jo</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2ARKP2KBCHBNoDf3V_1_JlcQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F1%2ARKP2KBCHBNoDf3V_1_JlcQ.jpeg" alt="Created using crello.com"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arguments in the failure report&lt;/li&gt;
&lt;li&gt;Running mix test with the failed flag&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Arguments in the failure report
&lt;/h2&gt;

&lt;p&gt;We mostly do assertions like&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  assert is_valid_card(card_type, card_number)
&lt;/h1&gt;
&lt;/blockquote&gt;

&lt;p&gt;without using any comparison operators like &lt;code&gt;&amp;lt; &amp;gt; &amp;lt;= == &amp;gt;=&lt;/code&gt; inside the unit test cases. Everybody likes being smart. Of course, I do too.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Personal Experience or impression to write this article:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I have had an experience on the peculiar behavior of maps with &lt;strong&gt;two&lt;/strong&gt; types of keys allowed to write a &lt;code&gt;map&lt;/code&gt; in elixir.&lt;/p&gt;

&lt;p&gt;I used a &lt;code&gt;map&lt;/code&gt; with &lt;code&gt;binary&lt;/code&gt; keys and trying to test them over a map with &lt;strong&gt;keys&lt;/strong&gt; of type &lt;code&gt;atom&lt;/code&gt;. Every time I do, the test gets failed. Though I am sending a correct &lt;code&gt;map&lt;/code&gt;, being the keys are of a different type, it gets failed.&lt;/p&gt;

&lt;p&gt;It took me a whole day to figure it out. 🌞&lt;/p&gt;

&lt;p&gt;I am always trying to debug the code &lt;strong&gt;&lt;em&gt;logic&lt;/em&gt;&lt;/strong&gt; instead of &lt;strong&gt;&lt;em&gt;arguments&lt;/em&gt;&lt;/strong&gt; that are passed. If the error report has this feature before, I could have saved a day in my life.&lt;/p&gt;

&lt;p&gt;Luckily we are having in the latest release.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;&lt;em&gt;Elixir 1.7&lt;/em&gt;&lt;/strong&gt; versions are smart enough to tell about the arguments given to the function, here &lt;code&gt;is_valid_card(card_type, card_number)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;As a programmer, I don’t like the documented proof. I always prefer the &lt;code&gt;test_cases&lt;/code&gt;. Well, let’s &lt;code&gt;test&lt;/code&gt; this feature.&lt;/p&gt;

&lt;p&gt;Before continuing further, I would like you to know the versions I am using at the moment of writing article.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F8576%2F1%2AtHDoidj5NGMYz6ost2pwKQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F8576%2F1%2AtHDoidj5NGMYz6ost2pwKQ.png" alt="**Elixir** and **Erlang** **OTP** versions"&gt;&lt;/a&gt;&lt;em&gt;**Elixir&lt;/em&gt;* and &lt;strong&gt;Erlang&lt;/strong&gt; &lt;strong&gt;OTP&lt;/strong&gt; versions*&lt;/p&gt;

&lt;p&gt;To test this feature, we will create a project &lt;code&gt;basic_math&lt;/code&gt; and a simple function &lt;code&gt;is_valid_card/2&lt;/code&gt; which is completely an &lt;strong&gt;idiot&lt;/strong&gt; one. This is used to check whether the given &lt;code&gt;card_number&lt;/code&gt; of &lt;code&gt;card_type&lt;/code&gt; is valid or not.&lt;/p&gt;

&lt;p&gt;We aren’t much worried to implement the complete logic here. The function, &lt;code&gt;is_valid_card/2&lt;/code&gt; does nothing useful just, it will just judge the length of the &lt;code&gt;card_number&lt;/code&gt; based on the &lt;code&gt;card_type&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="nv"&gt;$ &lt;/span&gt;mix new basic_math &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;basic_math
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above shell command creates a new Elixir project and changes your current working directory to the &lt;code&gt;basic_math&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Hope, you all knew the project structure. Well in case if you don’t, check out to&lt;a href="https://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html#our-first-project" rel="noopener noreferrer"&gt; My First Project in Elixir&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Open the file &lt;code&gt;lib/basic_math.ex&lt;/code&gt; and put the following lines of code.&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;#lib/basic_math.ex&lt;/span&gt;

&lt;span class="k"&gt;defmodule&lt;/span&gt; &lt;span class="no"&gt;BasicMath&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;

  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="n"&gt;is_valid_card&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;card_type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;card_number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;card_type&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="ss"&gt;:debit&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;
        &lt;span class="n"&gt;card_number&lt;/span&gt;
        &lt;span class="o"&gt;|&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;Integer&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;to_charlist&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="o"&gt;|&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;
        &lt;span class="o"&gt;|&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;Kernel&lt;/span&gt;&lt;span class="o"&gt;.==&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

       &lt;span class="ss"&gt;:credit&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;
        &lt;span class="n"&gt;card_number&lt;/span&gt;
        &lt;span class="o"&gt;|&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;Integer&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;to_charlist&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="o"&gt;|&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;
        &lt;span class="o"&gt;|&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;Kernel&lt;/span&gt;&lt;span class="o"&gt;.==&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="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="ss"&gt;:error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:invalid_card_type&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After adding the code, the file looks like in the following screenshot…&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2808%2F1%2AwpLmHTLkFpoo7pBneNioXA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2808%2F1%2AwpLmHTLkFpoo7pBneNioXA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Quick Docs about the code in basic_math.ex file.
&lt;/h3&gt;

&lt;p&gt;The definition &lt;code&gt;is_valid_card/2&lt;/code&gt; receives &lt;code&gt;two&lt;/code&gt; parameters &lt;code&gt;card_type&lt;/code&gt; and &lt;code&gt;card_number&lt;/code&gt; . We are case matching on &lt;code&gt;card_type&lt;/code&gt;. It matches for two case values &lt;code&gt;:credit &amp;amp; :debit&lt;/code&gt; and I hope you have understood the rest of the code. It is nothing harder than lifting a 1 gram of stone. Nothing like that, I am just kidding.&lt;/p&gt;

&lt;h3&gt;
  
  
  Unit Test Cases
&lt;/h3&gt;

&lt;p&gt;Now, we will write some unit test cases to test our code.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  Before using, test the code.
&lt;/h1&gt;
&lt;/blockquote&gt;

&lt;p&gt;Open the file &lt;code&gt;test/basic_math_test.exs&lt;/code&gt; and add the following lines of code&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic Setup&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Add the following code&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;defmodule&lt;/span&gt; &lt;span class="no"&gt;BasicMathTest&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="no"&gt;ExUnit&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="no"&gt;Case&lt;/span&gt;
  &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="no"&gt;BasicMath&lt;/span&gt;
  &lt;span class="n"&gt;doctest&lt;/span&gt; &lt;span class="no"&gt;BasicMath&lt;/span&gt;

&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Test Cases for debit card&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe "debit_card" do

     setup do
    {:ok, type: :debit, valid_card: 123456789012, invalid_card: 1234567890} 
     end

     test "valid debit card", %{type: type, valid_card: valid_card} do
      assert is_valid_card(type, valid_card)
     end

    test "in-valid debit card", %{type: type, invalid_card: invalid_card} do
      refute is_valid_card(type, invalid_card)
    end

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Test Cases for Credit card&lt;/strong&gt;&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;describe&lt;/span&gt; &lt;span class="s2"&gt;"credit_card"&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;setup&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="ss"&gt;:ok&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;type:&lt;/span&gt; &lt;span class="ss"&gt;:credit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;valid_card:&lt;/span&gt; &lt;span class="mi"&gt;123456789012&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;invalid_card:&lt;/span&gt; &lt;span class="mi"&gt;1234567890&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; 
    &lt;span class="k"&gt;end&lt;/span&gt;

    &lt;span class="n"&gt;test&lt;/span&gt; &lt;span class="s2"&gt;"valid credit card"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;%{&lt;/span&gt;&lt;span class="ss"&gt;type:&lt;/span&gt; &lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;valid_card:&lt;/span&gt; &lt;span class="n"&gt;valid_card&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="n"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;is_valid_card&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;valid_card&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;

    &lt;span class="n"&gt;test&lt;/span&gt; &lt;span class="s2"&gt;"in-valid credit card"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;%{&lt;/span&gt;&lt;span class="ss"&gt;type:&lt;/span&gt; &lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;invalid_card:&lt;/span&gt; &lt;span class="n"&gt;invalid_card&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="n"&gt;refute&lt;/span&gt; &lt;span class="n"&gt;is_valid_card&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;invalid_card&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the demo purpose, I purposely wrote some test cases to fail.&lt;/p&gt;

&lt;p&gt;The overall file looks like in the following screenshot&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3796%2F1%2Aq4J3Mt8u9_cfBe-dDYvc3A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3796%2F1%2Aq4J3Mt8u9_cfBe-dDYvc3A.png" alt="basic_math_test.exs"&gt;&lt;/a&gt;&lt;em&gt;basic_math_test.exs&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Under the credit_card section, we are using the same setup data used for debit_card unit test cases which eventually results in failure of the test cases.&lt;/p&gt;

&lt;p&gt;So, it will now include the value of each argument in the failure report: Let’s check that.&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="nv"&gt;$ &lt;/span&gt;mix &lt;span class="nb"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run your test cases using the above command. You will see the similar output as in the following screenshot.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3840%2F1%2ASlPz6vBSKVjYfy_84OMpRQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3840%2F1%2ASlPz6vBSKVjYfy_84OMpRQ.png" alt="mix test … testing the file basic_math.ex"&gt;&lt;/a&gt;&lt;em&gt;mix test … testing the file basic_math.ex&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you observe the above screenshot, Out of &lt;strong&gt;four(4),&lt;/strong&gt; **two(2) **test cases are failed and you can see the arguments passed to the test case in the failure report.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;arguments:

   #1
   :credit

   #2
   123467890
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This kinda failure report is very useful when our function is linked with too many functions. It is hard to debug the fail cause of a unit test case when the function is dependent on many other functions. This is where the arguments play the vital role in debugging the code failures.&lt;/p&gt;

&lt;p&gt;It is a great healthy feature. 💚&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Running mix test with a failed flag 🚩
&lt;/h2&gt;

&lt;p&gt;When you run the command mix test along with a flag--failed, It runs only the test cases that are failed in your previous attempt of mix test.&lt;/p&gt;

&lt;p&gt;It means this time the task mix test --failed don’t execute the successful test cases again. So, we can save the time here.&lt;/p&gt;

&lt;p&gt;The failed unit test cases are tracked and cached in a very first mix test&lt;/p&gt;

&lt;p&gt;We are having totally 4 unit test cases in the file. But, when you added the failed option, it gives out only 2 failed unit test cases.&lt;/p&gt;

&lt;p&gt;You can observe that in the following screenshot.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2A39Qx0qT-tikAADaBFcpRCQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2A39Qx0qT-tikAADaBFcpRCQ.png" alt="mix test — failed"&gt;&lt;/a&gt;&lt;em&gt;mix test — failed&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Hope you liked it.&lt;/p&gt;

&lt;p&gt;Happy long coding life… :)&lt;/p&gt;

</description>
      <category>elixir</category>
      <category>testing</category>
      <category>elixir17</category>
      <category>exunit</category>
    </item>
  </channel>
</rss>
