046_optionals2.patch 504 B

123456789101112131415161718192021
  1. 8,19d7
  2. < // We also introduce the handy ".?" shortcut:
  3. < //
  4. < // const foo = bar.?;
  5. < //
  6. < // is the same as
  7. < //
  8. < // const foo = bar orelse unreachable;
  9. < //
  10. < // See if you can find where we use this shortcut below.
  11. < //
  12. < // Now let's make those elephant tails optional!
  13. < //
  14. 24c12
  15. < tail: *Elephant = null, // Hmm... tail needs something...
  16. ---
  17. > tail: ?*Elephant = null, // <---- make this optional!
  18. 54c42
  19. < if (e.tail == null) ???;
  20. ---
  21. > if (e.tail == null) break;