mirror of
https://codeberg.org/ziglings/exercises.git
synced 2026-09-11 14:28:55 +00:00
fixed that @hasDecl only works on public functions now
This commit is contained in:
@@ -25,12 +25,12 @@ const Duck = struct {
|
||||
location_x: i32 = 0,
|
||||
location_y: i32 = 0,
|
||||
|
||||
fn waddle(self: *Duck, x: i16, y: i16) void {
|
||||
pub fn waddle(self: *Duck, x: i16, y: i16) void {
|
||||
self.location_x += x;
|
||||
self.location_y += y;
|
||||
}
|
||||
|
||||
fn quack(self: Duck) void {
|
||||
pub fn quack(self: Duck) void {
|
||||
if (self.loudness < 4) {
|
||||
print("\"Quack.\" ", .{});
|
||||
} else {
|
||||
@@ -44,12 +44,12 @@ const RubberDuck = struct {
|
||||
location_x: i32 = 0,
|
||||
location_y: i32 = 0,
|
||||
|
||||
fn waddle(self: *RubberDuck, x: i16, y: i16) void {
|
||||
pub fn waddle(self: *RubberDuck, x: i16, y: i16) void {
|
||||
self.location_x += x;
|
||||
self.location_y += y;
|
||||
}
|
||||
|
||||
fn quack(self: RubberDuck) void {
|
||||
pub fn quack(self: RubberDuck) void {
|
||||
// Assigning an expression to '_' allows us to safely
|
||||
// "use" the value while also ignoring it.
|
||||
_ = self;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
--- exercises/070_comptime5.zig 2023-10-03 22:15:22.125574535 +0200
|
||||
+++ answers/070_comptime5.zig 2023-10-05 20:04:07.159435482 +0200
|
||||
--- exercises/070_comptime5.zig 2026-08-31 13:28:01.202098783 +0200
|
||||
+++ answers/070_comptime5.zig 2026-08-31 13:27:33.431493595 +0200
|
||||
@@ -123,8 +123,8 @@
|
||||
// Please make sure MyType has both waddle() and quack()
|
||||
// methods:
|
||||
|
||||
Reference in New Issue
Block a user