Skip to content

Commit

Permalink
docs: object/objects: fix code examples (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
nobrayner authored Nov 25, 2024
1 parent ec5115f commit 0aab001
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions content/docs/object/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn init(app: *App) void {
});
// Print the monsters' health
const new_monster_id = app.monsters.get(new_monster_id);
const new_monster = app.monsters.get(new_monster_id);
std.debug.print("monster health: {}\n", .{new_monster.health});
// Give the monster 2x damage!
Expand All @@ -70,7 +70,10 @@ A core design decision of Mach's object system is to encourage you to _write cod
The first thing you might notice about the code snippet above is that when you create a new object, you get an _object ID_ back:

```zig
const new_monster_id = app.monsters.get(new_monster_id);
const new_monster_id: mach.ObjectID = app.monsters.new(.{
.health = 100,
.damage = 10,
});
```

Object IDs are just stable integer identifiers, containing _a ton of information_ in them:
Expand Down

0 comments on commit 0aab001

Please sign in to comment.