[Xotcl] init Constructor
Stefan Sobernig
stefan.sobernig at wu.ac.at
Sun May 26 11:04:25 CEST 2024
Hi Maksym!
Thank you for your Email!
> Hello, is it possible to pass data to init constructor in NX?
No, unless you would fiddle around (see below), NX, by default, does not
allow doing so (for good reasons).
> Without using properties, because I want to set up properties from init
> method.
What do you want to achieve? You can still process (e.g., validate) the
properties and object variables from within init, as it will be called.
But it won't receive, by default, the residual arguments to object
construction.
You should use an initblock script to call init explicitly, passing in
your arguments. (NX will ensure that the init is not called internally
for a second time.) Still, I recommend sticking with the property
mechanism.
HTH, Stefan
==
nx::Class create hello {
:method init {args} {
if {[llength $args] > 0} {
foreach name $args { puts "Hello: $name" }
}
}
}
::hello create helloObj [list :init [list Bruno Peter] ]
> Thank you
> _______________________________________________
> Xotcl mailing list
> Xotcl at alice.wu.ac.at
> http://alice.wu.ac.at/mailman/listinfo/xotcl
More information about the Xotcl
mailing list