swift - Is it possible to use the variable from an optional binding within the same conditional statement? -
if let popupbutton = result?.control as? nspopupbutto { if popupbutton.numberofitems <= 1 { // blahblah } }
i want avoid double nested if.
if let popupbutton = result?.control as? nspopupbutton && popupbutton.numberofitems <= 1 {}
but unresolved identifier
compiler error if that.
is there way make condition on 1 line? or because i'm using optional binding, forced make nested if
here?
you can way:
if let popupbutton = result?.control as? nspopupbutton, popupbutton.numberofitems <= 1 { //blahblah }
Comments
Post a Comment