Last active
June 13, 2019 22:38
-
-
Save joseoliv/9750202841204d509ba59c64ea34c3f1 to your computer and use it in GitHub Desktop.
init
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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