Macro.to_stringyou can see how our code is grouped.
||operator always returns the first expression which is true. Elixir doesn’t care about the remaining expressions, and won’t evaluate them after a match has been found.
nilis also false in elixir next
:blackodewhich evaluates to true and its value is returned immediately with out evaluating the
:jose. Similarly if all the statements evaluates to
falsethe last expression is returned.
&&returns the second expression if the first expression is
trueor else it returns the first expression with out evaluating the second expression. In the above examples the last one is the situation where we encounter to use the
"5" > 4unknowingly by an accident and to my surprise it returned with
number < atom < reference < fun < port < pid < tuple < map < list < bitstring (binary)
"$34.56"which is a string and I suppose do arithmetic operations. I usually do something like this before binary pattern matching..
^ctwice and restart shell as
iex -S mixwhenever I make changes to the project files. If you are doing this now, stop it right now. You can just recompile the project.
config/config.exare not reflected. You have to restart the shell again.
requirethis module. When I am new to Elixir, I always used to write the console outputs as
IO.puts "This is value of data"for code debugging but, those lines get mixed up with other lines of information and It became hard to trace those lines.
Loggermodule solved my problem. It has many features but, I use three definitions very often
errorEach definition prints the information with different colors which is more easy to find the statement at a glance.
Loggermodule one has to do
require Loggerso all macros will be loaded inside your working module.
.to retrieve the data from the keys as
map.keyunlike the usual notation like
map["key"]. That really saves the typing. But, I don’t encourage this because, as programmers we should really care about memory.
.form which is not present in the map, it will raise an key error instead of returning the
keyis not present in
>=1.4.0has ANSI color printing option to console. You can have great fun with colors. You can also provide background colors.