2 ms·
That is because you apply pattern matching when it is not really useful here, on top of avoiding a simple ternary operator. In some languages, you simply write
by bdisnainc 7y ago
That is because you apply pattern matching when it is not really useful here, on top of avoiding a simple ternary operator.
In some languages, you simply write:
if (user)
nameLabel.text = user.name;
else
nameLabel.text = "Guest";
Or:
nameLabel.text = user.name if user else "Guest"
Or anything along those lines. Concise, clear, no need for an extra operator.