summaryrefslogtreecommitdiff
path: root/example-container/Object.zig
blob: 22bc7a894e8c10830a654969b12fbc3885c696e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// File name starting with capital letters indicate a type definition.

// Alias for this type.
const Self = @This();

// Struct fields.
id: i32,
op: u32 = 42,

// Public static method, creating an Object.
pub fn init(v: i32) Self {
    return Self{ .id = v };
}

// Public member function.
pub fn dump(self: Self) void {
    const print = @import("std").debug.print;
    print("Self = {s}\n", .{@typeName(Self)});
    print("ID = {} OP = {}\n", .{ self.id, self.op });
}