Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Create another bird array that accept nil value
- let otherBirds: [Bird?] = [chicken, nil]
- let chicken4 = otherBirds[0] as? Chicken? // Cast successful: chicken4 type is Chicken??
- let chicken5 = otherBirds[0] as! Chicken? // Cast successful: chicken5 type is Chicken?
- let chicken6 = otherBirds[1] as? Chicken? // Cast failed: Trigger runtime error
- let chicken7 = otherBirds[1] as! Chicken? // Cast failed: Trigger runtime error
- let chicken8 = otherBirds[0] as? Chicken! // chicken8 type is Chicken?? | Warning: Using '!' here is deprecated and will be removed in a future release
- let chicken9 = otherBirds[0] as! Chicken! // chicken9 type is Chicken? | Warning: Using '!' here is deprecated and will be removed in a future release
Add Comment
Please, Sign In to add comment