009_if.zig 774 B

1234567891011121314151617181920212223242526272829303132
  1. //
  2. // Now we get into the fun stuff, starting with the 'if' statement!
  3. //
  4. // if (true) {
  5. // ...
  6. // } else {
  7. // ...
  8. // }
  9. //
  10. // Zig has the "usual" comparison operators such as:
  11. //
  12. // a == b means "a equals b"
  13. // a < b means "a is less than b"
  14. // a != b means "a does not equal b"
  15. //
  16. // The important thing about Zig's "if" is that it *only* accepts
  17. // boolean values. It won't coerce numbers or other types of data
  18. // to true and false.
  19. //
  20. const std = @import("std");
  21. pub fn main() void {
  22. const foo = 1;
  23. // Please fix this condition:
  24. if (foo) {
  25. // We want our program to print this message!
  26. std.debug.print("Foo is 1!\n", .{});
  27. } else {
  28. std.debug.print("Foo is not 1!\n", .{});
  29. }
  30. }