ios - Translate this line in Swift 2.0 to English -


i have ran line of code in infamous sevenswitch class.

here line...

backgroundview.layer.cornerradius = self.isrounded ? frame.size.height * 0.4 : 2 

i don't understand ? or : @ end of equation. please explain these mean , how used?

thanks bunch!

operators can unary, binary, or ternary:

this ternary operators operate on 3 targets. c, swift has 1 ternary operator, ternary conditional operator (a ? b : c).

from apple documents basic operators

ternary conditional operator

the ternary conditional operator special operator 3 parts, takes form question ? answer1 : answer2. shortcut evaluating 1 of 2 expressions based on whether question true or false. if question true, evaluates answer1 , returns value; otherwise, evaluates answer2 , returns value.

as per question if isround true corner radios frame.size.height else it's 2.

as if condition :

if(self.isrounded){     backgroundview.layer.cornerradius = frame.size.height * 0.4 } else{     backgroundview.layer.cornerradius = 2.0 } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -