How does one make an optional closure in swift? -
i'm trying declare argument in swift takes optional closure. function have declared looks this:
class promise{ func then(onfulfilled: ()->(), onreject: ()->()?){ if allow callablerjector = onreject { // stuff! } } }
but swift complains "bound value in conditional must optional type" "if let" declared.
you should enclose optional closure in parentheses. scope ?
operator.
func then(onfulfilled: ()->(), onreject: (()->())?){ if allow callablerjector = onreject { // stuff! } }
swift optional-parameters
No comments:
Post a Comment