#Alias is smaller than atom?

1 messages · Page 1 of 1 (latest)

dreamy dragon
#

I'm just getting started with the basics and bumped into cross-type comparison. Docs says it goes smaller to bigger like number < atom < reference ... So I wondered what happens to aliases. It turns out number < alias < atom when I do this.

73 < List and List < :ok
:ok < List == false

So I googled and figured that aliases resolve into atoms. But then why is it smaller than an atom?

solar forge
#

Aliases are atoms. And atoms are sorted according to their lexicographic order.

#

In the same sense :a < :b

dreamy dragon
solar forge
#

Do not understand the question. You should just assume that these will be in some arbitrary order, for your code that shouldn't really matter what that order is.

#

List == :"Elixir.List" BTW

dreamy dragon
#

I must be missing some simple concept here

solar forge
#

: and " are just syntax, it is not atom value

dreamy dragon
#

Yeah then L comes after a, why List < :a?

solar forge
#

L comes before a in ASCII

dreamy dragon
#

Ooh I see that was my confusion Thank you!

solar forge
#

Just remember that first letter of List atom is E 😉

dreamy dragon
night robin
#

Make sure to have a guard clause when comparing integers

dreamy dragon