博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Groovy入门
阅读量:2388 次
发布时间:2019-05-10

本文共 523 字,大约阅读时间需要 1 分钟。

def list = [1, 2, 3]list.each { e ->    print e}println()list << 4list.each {    print it //默认参数}println()//定义闭包def add = { a, b ->    println "a + b = ${a + b}"}def minus = { a, b ->    println "a - b = ${a - b}"}//调用闭包add 1, 2minus 1, 1//定义函数,参数类型为闭包def myfunc(a, b, Closure closure){    closure a, b}//调用函数myfunc 2, 2, { a, b ->    println "a * b = ${a * b}"}//调用函数myfunc 1, 1, minus//定义函数,只有一个参数,参数类型是闭包def show(Closure closure){    closure.call()}//调用函数,可以省略(),如果最后一个参数的类型是闭包,可以提取出来show {    println "hello the world"}
你可能感兴趣的文章
变量的变量,PHP和你
查看>>
PROC系列之四---/proc/loadavg
查看>>
某大型网站的内核TCP/ip优化脚本
查看>>
Defeating SSL using SSLStrip (Marlinspike Blackhat)
查看>>
大型网站数据库架构
查看>>
rdp 安全策略
查看>>
Threat Intelligence Quotient Test
查看>>
Cisco路由器上防止DDOS的一些建议
查看>>
系统安全防护之UNIX下入侵检测方法
查看>>
域控渗透技巧
查看>>
Minion security project and 分布式nmap
查看>>
防火墙相关
查看>>
网络性能测试工具Iperf上手指南
查看>>
opensecuritytraining video
查看>>
collective intelligence framework
查看>>
2015年关注的技术书籍
查看>>
windows 2003 server 记录远程桌面的连接登录日志和修改3389连接端口方法
查看>>
samhain:比较变态的入侵检测系统
查看>>
Linux psacct文档
查看>>
使用setuptools自动安装python模块
查看>>