0

Just being curious here, when is the desired moment (better readability?) for using ?: ?

I mean, obviously this:

points = (someBool) ? 0 : 10

is better than this:

if someBool {
    points = 0
} else {
    points = 10
}

but then no one would want to read this:

someView.isHidden ? updateViewVisibility(desired: .Visible, forView: someView) : updateViewVisibility(desired: .Hidden, forView: someView)

So is there a guideline for all of this? Or is this just a mood thing?

Ray Tso
  • 566
  • 9
  • 17

0 Answers0