pgreze
02/04/2021, 8:07 AMif __file__ == "__main__": hello("sample")
My use case is when using the @\Import feature.
Let’s imagine script1.main.kts:
@file:Import("script2.main.kts")
hello("john")
and script2.main.kts:
fun hello(name: String) = TODO(...)
// MAIN start
hello("sample") // executed even when imported
// MAIN end
Nikky
02/07/2021, 4:12 PMfun main()
in there
and call that function after doing the evaluation of the main script
the top level statements are always evaluated / executed
if you want to avoid that.. put it in a function and then call that function only if you needpgreze
02/09/2021, 6:21 AMNikky
02/09/2021, 8:36 AMinterface
/ open class
to use
you just need to cast the compiled script object to it at the endpgreze
02/09/2021, 12:21 PM