DEV Community

Discussion on: What are the great function/method/etc. names in popular libs/languages?

Collapse
 
manzanit0 profile image
Javier Garcia

.NET's FirstOrDefault() method when accessing LINQ. I find it super clear :)

Collapse
 
ben profile image
Ben Halpern

Less clear along those lines is the ||= operator.

Collapse
 
robencom profile image
robencom

Hey, PHP has the coolest operator: the SPACESHIP operator <=>

Thread Thread
 
kip13 profile image
kip

The <=> is for evaluation and ||= is for assigment, the ?? null coalescing operator is more close to it but are not the same.

Collapse
 
twigman08 profile image
Chad Smith

Now only if I could convince people to quit thinking FirstOrDefault will always return null if it can't find anything.

It does what it says it does, default value. It just so happens that for objects that is null
(I say this because I had to prove to someone once that their if statement would always evaluate to true. Lol)