006_strings.patch 878 B

123456789101112131415161718192021222324
  1. --- exercises/006_strings.zig 2023-10-03 22:15:22.122241138 +0200
  2. +++ answers/006_strings.zig 2023-10-05 20:04:06.869430053 +0200
  3. @@ -24,18 +24,18 @@
  4. // (Problem 1)
  5. // Use array square bracket syntax to get the letter 'd' from
  6. // the string "stardust" above.
  7. - const d: u8 = ziggy[???];
  8. + const d: u8 = ziggy[4];
  9. // (Problem 2)
  10. // Use the array repeat '**' operator to make "ha ha ha ".
  11. - const laugh = "ha " ???;
  12. + const laugh = "ha " ** 3;
  13. // (Problem 3)
  14. // Use the array concatenation '++' operator to make "Major Tom".
  15. // (You'll need to add a space as well!)
  16. const major = "Major";
  17. const tom = "Tom";
  18. - const major_tom = major ??? tom;
  19. + const major_tom = major ++ " " ++ tom;
  20. // That's all the problems. Let's see our results:
  21. std.debug.print("d={u} {s}{s}\n", .{ d, laugh, major_tom });