Reputation: 23
The following code is used to work in Swift 2
:
let endpoint = EndpointManager(endpoint: userType == .Pro ? .ProFollowing(identifier, url) : .FanFollowing(identifier, url), method: .get, parameters: nil)
Now it gives the error:
Expression type bool is ambiguous without more context
The following solution worked for me:
var following : Endpoint
if userType == .pro {
following = Endpoint.proFollowing(identifier,url)
}
else {
following = Endpoint.fanFollowing(identifier,url)
}
let endpoint = EndpointManager(endpoint: following, method: .get, parameters: nil)
Upvotes: 0
Views: 1636
Reputation: 27211
You have to wrap bool parameter by parenthesis:
let isProFollowing = userType == .Pro ? .ProFollowing(identifier, url)
let following: YourEnumType = isProFollowing ? .ProFollowing(identifier, url) : .FanFollowing(identifier, url)
let endpoint = EndpointManager(endpoint: following, method: .get, parameters: nil)
colon sign confuses your XCode
Upvotes: 0