user
Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10. Include all bounds checking you need to write, or explain how the compiler or interpreter creates those bounds checks for you.
assistant
(formerly Perl 6)

```
subset OneToTen of Int where 1..10;

my OneToTen $n = 5;
$n += 6;

```

Here the result 11 fails to smartmatch against the range `1..10`, so the second assignment throws an exception. You may use any valid smartmatch predicate within a `where` clause, so the following one-argument closure is also legal:

```
subset Prime of Int where -> $n { $n > 1 and so $n %% none 2 .. $n.sqrt }

```