Set or remove a value restriction on a thing. Function restriction() can be used to view the current restriction.
This function generates a change.
thing.restrict(type)
Argument | Type | Description |
---|---|---|
type | str/nil (required) | Restriction to set on the thing or nil to remove a restriction. |
Returns the thing
Use
restrict()
to force int values on a thing;
example = {}.restrict('int');
example.x = 10; // this is OK
assert ( is_err ( try ( example.name = 'Iris' ))); // values must be int
example; // only `x` is set
Return value in JSON format
{
"x": 10
}