I just want to know what is the difference between if..else
and Nil-Coalescing
Operator and it's main use.
- Syntax with
Nil-Coalescing
Operator.
lblGenres.textColor = genreSelected.contains(indexPath.row) ? colorWithHex(hex: COLORCODE.APP_THEME_COLOR) : colorWithHex(hex: COLORCODE.BLACK_COLOR)
if..else
statement
if genreSelected.contains(indexPath.row)
{
lblGenres.textColor = colorWithHex(hex: COLORCODE.APP_THEME_COLOR)
}
else
{
lblGenres.textColor = colorWithHex(hex: COLORCODE.BLACK_COLOR)
}
Here i get both works properly but with the using of Nil-Coalescing
Operator make syntax easy.
- So i just want to know that, which
condition
oroperator
use is good and why?
Aucun commentaire:
Enregistrer un commentaire