More elvis operations

It would be nice to have more Elvis operations. for example

val :Int = List.size <: 0

So you can not only check for null/? with Elvis but also <,>,=
Elvis < == Is null or is smaller then 0
Elvis > == Is null or is bigger then 0
And so on…

I don’t really understand this example. First, List.size can’t be null here, so it is comparing two not-null values. Second, the result seems to be boolean, but you typed it as integer.

Do you mean that a <: b should work like this?

if (a == null) true else a < b

Then why it should return specifically true in null case? Why not false? Why not null? Sounds like designing the language to solve one specific kind of problems.

edit:

Or maybe you mean something like this:

if (a < b) a else null

It is not very clear what do you mean.

1 Like

?.let{} covers all those cases, it does not make sense to add them to the language.