From 55ad7c32f2d534b1fbd438204d21738f958c51a5 Mon Sep 17 00:00:00 2001 From: Dave Gauer Date: Tue, 9 Feb 2021 18:36:57 -0500 Subject: Moved exercises to exercises because exercises --- 36_enums2.zig | 61 ----------------------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 36_enums2.zig (limited to '36_enums2.zig') diff --git a/36_enums2.zig b/36_enums2.zig deleted file mode 100644 index 2e04415..0000000 --- a/36_enums2.zig +++ /dev/null @@ -1,61 +0,0 @@ -// -// Enums are really just a set of numbers. You can leave the -// numbering up to the compiler, or you can assign them -// explicitly. You can even specify the numeric type used. -// -// const Stuff = enum(u8){ foo = 16 }; -// -// You can get the integer out with a built-in function: -// -// var my_stuff: u8 = @enumToInt(Stuff.foo); -// -// Note how that built-in function starts with "@" just like the -// @import() function we've been using. -// -const std = @import("std"); - -// Zig lets us write integers in hexadecimal format: -// -// 0xf (is the value 15 in hex) -// -// Web browsers let us specify colors using a hexadecimal -// number where each byte represents the brightness of the -// Red, Green, or Blue component (RGB) where two hex digits -// are one byte with a value range of 0-255: -// -// #RRGGBB -// -// Please define and use a pure blue value Color: -const Color = enum(u32){ - red = 0xff0000, - green = 0x00ff00, - blue = ???, -}; - -pub fn main() void { - // Remeber Zig's multi-line strings? Here they are again. - // Also, check out this cool format string: - // - // {x:0>6} - // ^ - // x type ('x' is lower-case hexadecimal) - // : separator (needed for format syntax) - // 0 padding character (default is ' ') - // > alignment ('>' aligns right) - // 6 width (use padding to force width) - // - // Please add this formatting to the blue value. - // (Even better, experiment without it, or try parts of it - // to see what prints!) - std.debug.print( - \\

- \\ Red - \\ Green - \\ Blue - \\

- , .{ - @enumToInt(Color.red), - @enumToInt(Color.green), - @enumToInt(???), // Oops! We're missing something! - }); -} -- cgit v1.2.3-ZIG