groovy 速学 - 03 - 脚本
发布时间:2020-12-14 16:48:05 所属栏目:大数据 来源:网络整理
导读:目录 脚本 运行脚本 绑定变量 摘要 运行脚本,绑定域 脚本 运行脚本 从命令行中运行指定脚本 groovy example.groovy 在其它程序中运行指定脚本 //有一脚本文件 example.groovy def s = new example()s.run() 也可以通过该脚本对象直接运行脚本内的函数 绑定
目录
摘要
脚本运行脚本从命令行中运行指定脚本 groovy example.groovy 在其它程序中运行指定脚本 //有一脚本文件 example.groovy
def s = new example()
s.run()
也可以通过该脚本对象直接运行脚本内的函数 绑定变量通过 new 建立的脚本对象可以绑定指定的值到该脚本的绑定域中 //file: example.groovy
//绑定域
helloworld = "hello world"
def hello(){
println(helloworld)
}
//file: other.groovy
def s = new example()
s.binding.goodbye = "good bye" //绑定不存在的变量不会报错
s.binding.helloworld = "hello groovy"
s.hello() //hello groovy
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |