Use The Null Coalescing Operator For Cleaner Code #shorts

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

It does not look awful at all. However, why would someone return a default value if user is not found? returning null is better

ardavaztterterian
Автор

If user is not null it will return user or what?

arkadiuszszczotka
Автор

Better readability for the 1st approach

danutpenciuc
Автор

What problem does this solve? Let's say you want to show a 404 page when the user doesn't exist.
Your're going to write this:
if(user == User.Default)
{
return 404;
}

So you just moved the if() to another place.

Chris-zbnm