Skip to content

Instantly share code, notes, and snippets.

@Makazone
Created January 27, 2016 20:39
Show Gist options
  • Save Makazone/339730b8b3d85fd7bad2 to your computer and use it in GitHub Desktop.
Save Makazone/339730b8b3d85fd7bad2 to your computer and use it in GitHub Desktop.
Protocol inheritance in Swift
//: Playground - noun: a place where people can play
import UIKit
protocol A { }
protocol B: A { }
class MyClass: B { }
let b: [B] = (1...3).map { MyClass(indx: $0) }
// Cannot convert value of type '[B]' to specified type '[A]'
let a: [A] = b
@Makazone
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment