Skip to content

Instantly share code, notes, and snippets.

@joseoliv joseoliv/Init.cyan
Last active Jun 13, 2019

Embed
What would you like to do?
init
package metaobjectTest
@doc{*
Annotation 'init' creates a method 'init:' based on a list
of fields to initialize
*}
object Init
func init {
max = 1000;
}
// ok, name and lastLetter receive values in their declarations
@init(max)
@init(name, lastLetter, max)
// compilation error if uncommented: max need to be initialized
// @init(name, lastLetter)
@init(name, max)
func run {
var p0 = Init(1000);
var p1 = Init new: "other", 'Z', 50;
var p2 = Init new: "other", 5000;
}
let String name = "init";
var Char lastLetter = 'z';
var Int max
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.