Created
May 14, 2017 22:01
-
-
Save koher/d62e4dbafe0687f1a708b53b5ed21cd4 to your computer and use it in GitHub Desktop.
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
class Animal {} | |
class Cat: Animal {} | |
let cats: Array<Cat> = [Cat()] | |
let animals: Array<Animal> = cats // OK | |
let cat: Optional<Cat> = .some(Cat()) | |
let animal: Optional<Animal> = cat // OK | |
struct Box<Value> { | |
var value: Value | |
} | |
let catBox: Box<Cat> = Box(value: Cat()) | |
let animalBox: Box<Animal> = catBox // error: cannot convert value of type 'Box<Cat>' to specified type 'Box<Animal>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment