i am learning zig and i have some simple code where i try to declare a method on a struct and try to call that method
here is the code
pub fn main() void {
const Example = struct {
a: i8,
b: i8,
c: u6 = 5,
fn prettyPrint(self: *Example) void {
std.debug.print(" a ---> {}\n b ---> {}\n c ---> {}", .{self.a, self.b, self.c});
}
};
var ex: Example = .{.a = 1, .b =1};
ex.prettyPrint();
}
but it fails with the following error
zig run ziggity.zig
ziggity.zig:29:31: error: use of undeclared identifier 'Example'
fn prettyPrint(self: *Example) void {
^
i am on zig version 0.10.0-dev.2024+d127c1d59
what seems to be wrong here?