Created
May 28, 2015 19:49
-
-
Save wjlafrance/785f4158532dcf70d10f to your computer and use it in GitHub Desktop.
ThisIsNotTheErrorYouAreLookingFor.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is an object we want to JSON encode. We need to know if it's a dictionary or array. | |
let instance: AnyObject = [1, 2, 3] as! AnyObject | |
// Checking if an object is a non-parameterized generic type is not supported | |
if instance is Array { // Argument for generic parameter 'T' could not be inferred | |
println("It's an array") | |
} | |
// When combing the two `is` checks, each independently invalid, the compiler shows the wrong errror. | |
// Thanks to @eridius for helping debug this. | |
if instance is Array || instance is Dictionary { // Binary operator '||' cannot be applied to two Bool operands | |
println("It's an array or dictionary") | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment