You should enclose the optional closure in parentheses. This will properly scope the ?
operator.
func then(onFulfilled: ()->(), onReject: (()->())?){
if let callableRjector = onReject {
// do stuff!
}
}
More Related Contents:
- How to seed the Int.random method call in Swift?
- Migrating Swift code to Swift 3.0 LOADS of errors
- Overriding methods in Swift extensions
- Alternative to performSelector in Swift?
- NSObject subclass in Swift: hash vs hashValue, isEqual vs ==
- creating custom tableview cells in swift
- Return instancetype in Swift
- Swift protocol extension method is called instead of method implemented in subclass
- NSURLSession concurrent requests with Alamofire
- Does Swift have documentation generation support?
- Get integer value from string in swift
- Why constant constraints the property from a structure instance but not the class instance?
- == overload for custom class is not always called
- Is it possible to replicate Swifts automatic numeric value bridging to Foundation (NSNumber) for (U)Int8/16/32/64 types?
- Sheet inside ForEach doesn’t loop over items SwiftUI
- Does swift copy on write for all structs?
- Fetch data from CoreData for iOS 14 widget
- fatal error: swapping a location with itself is not supported with Swift 2.0
- How do I import a Swift file from another Swift file?
- What is the point of having two different names for the same parameter?
- Swift lazy instantiating using self
- Swift – How to mutate a struct object when iterating over it
- How to use a @FetchRequest with the new searchable modifier in SwiftUI?
- No such module ‘RestKit’ with cocoapods and swift
- What’s the difference between using ARAnchor to insert a node and directly insert a node?
- Use Cocoapods with an App Extension
- How to remove “row” separators/dividers from a List in SwiftUI?
- Increase the size of the indicator in UIPageViewController’s UIPageControl
- How do I programmatically move an ARAnchor?
- Whats the Swift animate WithDuration syntax?