Why is nil> 0 true in Erlang?

Erlang is the first language I come across to give true for nil> 0.

What is the history of this decision?

Other languages ​​seem to behave differently.

Python:

None > 0
# False

JavaScript:

null > 0
// false

Ruby:

nil > 0
NoMethodError: undefined method `>' for nil:NilClass
+3
source share
1 answer

In Erlang, any member can be compared to any other member. The order of comparison of Erlang terms:

number < atom < reference < fun < port < pid < tuple < map < nil < list < bit string

this way nil> 0 true More information on Timing comparisons

+8
source

Source: https://habr.com/ru/post/1666546/


All Articles