009_if.zig 799 B

12345678910111213141516171819202122232425262728293031323334
  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 is greater than b"
  15. // a != b means "a does not equal b"
  16. //
  17. // The important thing about Zig's "if" is that it *only* accepts
  18. // boolean values. It won't coerce numbers or other types of data
  19. // to true and false.
  20. //
  21. const std = @import("std");
  22. pub fn main() void{
  23. const foo = 1;
  24. // Please fix this condition:
  25. if(foo == 1){
  26. // We want our program to print this message!
  27. std.debug.print("Foo is 1!\n", .{});
  28. }else{
  29. std.debug.print("Foo is not 1!\n", .{});
  30. }
  31. }