groovy的错误
来源:互联网 发布:老司机网站 知乎 编辑:程序博客网 时间:2024/06/05 12:40
1.Cannot cast object 'org.codehaus.groovy.runtime.MethodClosure@92d6d2' with class 'org.codehaus.groovy.runtime.MethodClosure' to class 'Closure'
class MethodClosureSample {int limitpublic MethodClosureSample(int limit) {this.limit = limit}boolean validate(String value){return value.length() <= limit}static main(args) {MethodClosureSample first = new MethodClosureSample(6)MethodClosureSample second = new MethodClosureSample(5)Closure firstClosure = first.&validatedef words = ['long string','medium','short','tiny']assert 'medium' == words.find(firstClosure)assert 'short' == words.find(second.&validate)}}
如上代码改成如下的形式:
class MethodClosureSample {int limitpublic MethodClosureSample(int limit) {this.limit = limit}boolean validate(String value){return value.length() <= limit}static main(args) {MethodClosureSample first = new MethodClosureSample(6)MethodClosureSample second = new MethodClosureSample(5)org.codehaus.groovy.runtime.MethodClosure firstClosure = first.&validatedef words = ['long string','medium','short','tiny']assert 'medium' == words.find(firstClosure)assert 'short' == words.find(second.&validate)}}
- groovy的错误
- Groovy错误笔记1
- Groovy:简单的介绍Groovy
- 【Groovy手札】Groovy的字符串
- 【Groovy手札】Groovy的List
- 实战 Groovy: Groovy:Java 程序员的 DSL
- 实战 Groovy: Groovy:Java 程序员的 DSL
- 【Groovy手札】Groovy的几种注释
- 很诡异的Groovy
- groovy 的陷阱
- Groovy的一些Map
- Groovy 的腾飞
- Groovy的Loop
- Groovy的IDE
- Groovy的基础语法
- Groovy的闭包
- Groovy的集合类型
- Groovy的资源处理
- ORA-12514 TNS 监听程序当前无法识别连接描述符中请求服务
- iphone4的修改host的步骤
- 我的第一篇博客+程序员的十层楼
- 《高性能网站建设指南》阅读笔记_规则9- 减少DNS查找
- lftp上传下载限速
- groovy的错误
- 全局变量、局部变量、静态全局变量、静态局部变量的区别
- ubuntu12.04 64bit 常见问题
- C语言:指针的三道编程练习
- Complete Search
- HDU 1241 Oil Deposits DFS入门
- 回归结对编程
- AES 加密
- sqlprofile监控SP常用事件