diff --git a/src/context.zig b/src/context.zig index 8b5dd92..63da514 100644 --- a/src/context.zig +++ b/src/context.zig @@ -105,6 +105,9 @@ pub const Context = struct { return current; } + pub fn getOr(self: *Context, path: []const u8, default: anytype) ?Value { + return self.get(path) orelse try self.toValue(default); + } // pub fn get(self: *const Context, comptime T: type, key: []const u8) !T { // // const opt_value = self.map.get(key) orelse return error.KeyNotFound;