aboutsummaryrefslogtreecommitdiff
path: root/exercises/38_structs2.zig
diff options
context:
space:
mode:
authorDave Gauer <ratfactor@gmail.com>2021-02-15 19:32:00 -0500
committerGitHub <noreply@github.com>2021-02-15 19:32:00 -0500
commit09fd739efa9cee151c8300f53c422d8a72766d49 (patch)
tree45f2eba30d72f43df60cd9b053ebaea5dfe11f18 /exercises/38_structs2.zig
parent0d212ecf5a9de1c0bb673a2b6a409de5a99a9d7b (diff)
parent304489ca1f465b5456fa8c21dd0ae4e4c6c48617 (diff)
downloadziglings-09fd739efa9cee151c8300f53c422d8a72766d49.tar.gz
ziglings-09fd739efa9cee151c8300f53c422d8a72766d49.tar.bz2
ziglings-09fd739efa9cee151c8300f53c422d8a72766d49.tar.xz
ziglings-09fd739efa9cee151c8300f53c422d8a72766d49.zip
Merge pull request #22 from quexxon/apply-zig-fmt
Apply `zig fmt` to exercises and generate remaining patch files
Diffstat (limited to 'exercises/38_structs2.zig')
-rw-r--r--exercises/38_structs2.zig17
1 files changed, 9 insertions, 8 deletions
diff --git a/exercises/38_structs2.zig b/exercises/38_structs2.zig
index b6def93..b0db022 100644
--- a/exercises/38_structs2.zig
+++ b/exercises/38_structs2.zig
@@ -2,20 +2,20 @@
// Grouping values in structs is not merely convenient. It also allows
// us to treat the values as a single item when storing them, passing
// them to functions, etc.
-//
+//
// This exercise demonstrates how we can store structs in an array and
// how doing so lets us print them all (both) using a loop.
//
const std = @import("std");
-const Class = enum{
+const Class = enum {
wizard,
thief,
bard,
warrior,
};
-const Character = struct{
+const Character = struct {
class: Class,
gold: u32,
health: u8,
@@ -27,9 +27,9 @@ pub fn main() void {
// Glorp the Wise
chars[0] = Character{
- .class = Class.wizard,
- .gold = 20,
- .health = 100,
+ .class = Class.wizard,
+ .gold = 20,
+ .health = 100,
.experience = 10,
};
@@ -45,7 +45,8 @@ pub fn main() void {
// Printing all RPG characters in a loop:
for (chars) |c, num| {
- std.debug.print("Character {} - G:{} H:{} XP:{}\n",
- .{num+1, c.gold, c.health, c.experience});
+ std.debug.print("Character {} - G:{} H:{} XP:{}\n", .{
+ num + 1, c.gold, c.health, c.experience,
+ });
}
}