以 groovy 的方式实现接口

2015-12-14 0 1,006
以 groovy 的方式实现接口
//如果接口只有一个方法,可以通过闭包,用下面的方式来实现:

 // a readable puts chars into a CharBuffer and returns the count of chars added
def readable = { it.put("12 34".reverse()); 5 } as Readable

// the Scanner constructor can take a Readable
def s = new Scanner(readable)
assert s.nextInt() == 43

遇见资源网 groovy 以 groovy 的方式实现接口 http://www.ox520.com/13773.html

上一篇:

已经没有上一篇了!

下一篇:

已经没有下一篇了!

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务