Skip to content

Instantly share code, notes, and snippets.



Last active Jun 13, 2019
What would you like to do?
restrict the values a variable can hold
package metaobjectTest
Annotation 'type' should be attached to a type. It checks whether
the value of the type obeys the expression that is attached to
the annotation
object RestrictTo
func run {
var Int@restrictTo{* self >= 0 *} age;
age = 0;
age = 10;
var ok = false;
age = -1;
} catch: { (: CyException e :)
ok = true
assert ok;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment