Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
package metaobjectTest
Annotation 'immutable' should be attached to a prototype. It checks
whether the prototype is immutable (no field can change its value
after the object creation). Then an immutable prototype should
only be inherit by immutable prototypes and all of its fields
should be declared with 'let' and their types should be
immutable. All basic types (Int, String, ...), Any, and Nil
are immutable.
object Immutable
func run {
let String name = "Immutable";
// error if uncommented, 'var' is not allowed
// var Int Max = 100;
// error if uncommented, 'Array<Int>' is not immutable
// let Array<Int> array;
// ok
let ImArray<Int> iarray;
let Nil nil;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment