Swift func - Does not conform to protocol "Boolean Type"

Edward Hasted

Yes it's man vs compiler time and the compiler winning yet again! In the func getRecordNumber I am returning a Bool and a Dictionary

func getRecordNumber(recordNumber: Int32) -> (isGot: Bool, dictLocations: Dictionary <String, Double>)
...
return (isGot, dictLocations)

However after I have called the func and question the Boolean isGot return I get the error message

(isGot: Bool, dictLocations: Dictionary <String, Double>) Does not conform to protocol "Boolean Type"  

Any ideas what I have left out?

Dharmesh Kheni

You don't need to add parameters into return like this (isGot: Bool, dictLocations: Dictionary <String, Double>). you just need to tell compiler that what type this function will return.

Here is the correct way to achieve that:

func getRecordNumber(recordNumber: Int32) -> (Bool, Dictionary <String, Double>)
{
    let isGot = Bool()
    let dictLocations = [String: Double]()

    return (isGot, dictLocations)
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Type '()' does not conform to protocol 'Boolean Type'

Swift does not conform to protocol

Swift: type does not conform to protocol

Swift: Does not conform to protocol NSCoding

Swift - Type 'CircularTransition' does not conform to protocol 'UIViewControllerAnimatedTransitioning'

Swift AppDeligate does not conform to protocol 'MessagingDelegate'

Swift type does not conform to protocol NilLiteralConvertible

Swift - MultipeerConnectivity Type does not conform to protocol

Type "myViewController" does not conform to protocol UIPIckerDataSource in Swift

type does not conform to protocol Sequence Type - Swift

Swift - Type 'MenuViewController' does not conform to protocol 'GKGameCenterControllerDelegate'

Swift 2.1 ErrorType does not conform protocol RawRepresentable

Swift: Type 'ViewController' does not conform to protocol 'UIPageViewControllerDataSource'

swift 3 error: does not conform to protocol ‘UITableViewDataSource’

Swift 3 : AppDelegate does not conform to protocol GIDSignInDelegate

Swift - Type '' does not conform to protocol 'Hashable'

Swift class does not conform to Protocol with Enum

Swift NSManagedObject does not conform to protocol sequence Type

Swift Generic Implementation of protocol throws error `Type does not conform to protocol`

Swift Type "SceneName" does not conform to protocol ADInterstitialAdDelegate - SK Swift

Conform to protocol in ViewController, in Swift

Swift conform to protocol subclass

'ViewController' does not conform to protocol

Does not conform to protocol Decodable

Class does not conform to protocol

Type does not conform to protocol

Type () does not conform to protocol

UIPageViewController - Does not conform to protocol

protocol extension, does not conform to protocol