-1

What does the following code do?

Tracker t = (trackerId == TrackerName.APP_TRACKER) ? analytics.newTracker(PROPERTY_ID)
                : (trackerId == TrackerName.GLOBAL_TRACKER) ? analytics.newTracker(R.xml.global_tracker)
                : analytics.newTracker(R.xml.ecommerce_tracker);
ARK
  • 3,734
  • 3
  • 26
  • 29
  • I did not get this question in the search query. Please clone it rather than marking it as a duplicate. – ARK Jan 28 '15 at 21:31

2 Answers2

1

condition ? //block1 : //block2 is the same thing as if (condition) { //block1 } else { //block2 }

Dave
  • 1,784
  • 2
  • 23
  • 35
0

Your expression shall be a ? b : c. This means: If a, then do b. Otherwise do c.

What you have here is a nested version of this syntax.

paolo
  • 2,528
  • 3
  • 17
  • 25