jeudi 1 septembre 2016

"?:" instead of "if else" statement with Boolean not always working

Why this

isWorldRanking ? sIsWorldAdapterInitiated = true : sIsCountryAdapterInitiated = true;

is not working (with error Variable expected)? Works only when I use if else statement...

E.g. this:

otherList.get(i).setFollowersCountry(isFavorite ? otherList.get(i).getFollowersCountry() + 1 : otherList.get(i).getFollowersCountry() - 1);

and this:

List<FamousTop40Ranking> otherList = mIsWorldRanking ? sCountryFamousModelList : sWorldFamousModelList;

are working :)

Of course Boolean isWorldRanking, isFavorite.

Can you help?

Aucun commentaire:

Enregistrer un commentaire