Guest User

Untitled

a guest
Dec 14th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. // Create another bird array that accept nil value
  2. let otherBirds: [Bird?] = [chicken, nil]
  3. let chicken4 = otherBirds[0] as? Chicken? // Cast successful: chicken4 type is Chicken??
  4. let chicken5 = otherBirds[0] as! Chicken? // Cast successful: chicken5 type is Chicken?
  5.  
  6. let chicken6 = otherBirds[1] as? Chicken? // Cast failed: Trigger runtime error
  7. let chicken7 = otherBirds[1] as! Chicken? // Cast failed: Trigger runtime error
  8.  
  9. let chicken8 = otherBirds[0] as? Chicken! // chicken8 type is Chicken?? | Warning: Using '!' here is deprecated and will be removed in a future release
  10. 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