summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorChris Boesch <chrboesch@noreply.codeberg.org>2023-03-30 22:49:10 +0200
committerGitHub <noreply@github.com>2023-03-30 22:49:10 +0200
commitaa01f6eea94e40e7e24e7ef20d109139acf0c7d1 (patch)
treeb732e05e643b906ff629996e8c9ec3931072b3eb
parent87ddb98d23d0dc700a184fa2ce0001e6ba21a2ea (diff)
parent34e36e41751b2361ce9a4d2f96c5ff42dbe2cd05 (diff)
Merge pull request #207 from chrboesch/i205
changed self paramter in waddle to pointer
-rw-r--r--exercises/070_comptime5.zig8
1 files changed, 4 insertions, 4 deletions
diff --git a/exercises/070_comptime5.zig b/exercises/070_comptime5.zig
index 01f4276..c078573 100644
--- a/exercises/070_comptime5.zig
+++ b/exercises/070_comptime5.zig
@@ -25,7 +25,7 @@ const Duck = struct {
location_x: i32 = 0,
location_y: i32 = 0,
- fn waddle(self: Duck, x: i16, y: i16) void {
+ fn waddle(self: *Duck, x: i16, y: i16) void {
self.location_x += x;
self.location_y += y;
}
@@ -44,7 +44,7 @@ const RubberDuck = struct {
location_x: i32 = 0,
location_y: i32 = 0,
- fn waddle(self: RubberDuck, x: i16, y: i16) void {
+ fn waddle(self: *RubberDuck, x: i16, y: i16) void {
self.location_x += x;
self.location_y += y;
}
@@ -83,14 +83,14 @@ const DuctError = error{UnmatchedDiameters};
pub fn main() void {
// This is a real duck!
- const ducky1 = Duck{
+ var ducky1 = Duck{
.eggs = 0,
.loudness = 3,
};
// This is not a real duck, but it has quack() and waddle()
// abilities, so it's still a "duck".
- const ducky2 = RubberDuck{
+ var ducky2 = RubberDuck{
.in_bath = false,
};