且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Groovy 脚本中创建类

更新时间:2023-12-05 14:47:52

在 groovy 脚本中,您可以像这样声明和访问它的静态方法:

in groovy script you can declare and access static methods of it like this:

class A{
    static void greet(String name){
        println "hello $name!"
    }
}

//code without class declaration will be executed as part of script.run() method 
A.greet("world")