Today my little brain got one of the concepts that I wasn't quite getting.
What is this thing about Elixir evaluating operations from right to left when it comes to lists? I can hear José Valim giggle: "this is going to break a few brains, mwahahahahaha".
Ok, José, close call, but I got this one. Gimme something trickier.
I was initially confused by this:
WHAAAAAAAAAAAT thaaa
2?
But, but, one minus one is zero and two minus two is zero, so one and two minus one and minus two...
So I went back to Apples And Oranges. Sesame-Street my life.
Here is my genius achievement of the day. One more step to Elixir Everest.
Here is looking at you, José
git add .
git commit -m "I am sure there is a reason for this madness"
BigSpaces
Top comments (3)
@bigspaces I can resolve your issue. This operator is right associative. Let's check Elixir docs for
Kernel.--/2
.The last example is exactly as you defined in your post. Technically it will be executed as:
I know, it's probably really exploding head moment but "working as expected :D"
Comparing apples and oranges is how I intially thought of this when I was working through it yesterday. Try expanding the left side to apples oranges and lemons and see if that breaks your head! 😆
If you could only see my LiveBook now... it is a full shopping list