Me casually typing an Ecto validation in VSCode
|> validate_number(:pay, greater_than: 0, less_than: 9999999)
I have auto-formatting enabled on Save… VSCode changes the code into the following
|> validate_number(:pay, greater_than: 0, less_than: 9_999_999)
I go WTH… did I make a typo, why did the formatter do such a thing? I mean it is nicer but… let me search
Numbers
Integers (
1234
) and floats (123.4
) in Elixir are represented as a sequence of digits that may be separated by underscore for readability purposes, such as1_000_000
. Integers never contain a dot (.
) in their representation. Floats contain a dot and at least one other digit after the dot. Floats also support the scientific notation, such as123.4e10
or123.4E10
.
awe, now I like you more