5

According to solidity docs the type address has the following operators:

<=, <, ==, !=, >= and >

Besides checking for equality - Why would I want to check if an address is greater or smaller than another one? What is the usecase?

6

An address is a 20 byte number, so it gets comparison operators for free: Solidity doesn't have to implement anything, and the gas costs for using them are the same as comparing integers.

In the future, the comparison operators might be useful depending on how in Ethereum works. For example, one of the simplest and early ideas was to shard according to address space, like shard1 contains the first billion addresses, shard2 contains the next billion, and so on. A contract might then use the comparison operators to determine which shard another contract was in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.