groovy in actions 笔记 1

本文分享了使用Groovy编程语言进行的两个实践案例:逐行读取并打印文件内容及提取类包名称的方法。作者决定利用手中的英文版《Groovy in Action》PDF资源进行学习,并通过实际编程加深理解。
不准备买groovy in action的书了,既然手上有pdf版本的,虽然是英文版本的,也就将就着看吧,xy知道自己迟早必须看纯英文的技术书。

看英文书虽然生词很多,不过大致意思能懂,而且写代码的时候不会有差。然而不能一次看时间太长,这个其实不是因为英文的问题,自己在看中文的书的时候也有这个问题,简单来说就是注意力持续不了多久。

闲话少说,xy不打算搬原文上来,只是放几个自己消化吸收的例子程序段上来。

一个是输入文件,然后逐行打印文件的程序,简单的closures(闭包)程序。这个其实可以拿shell来弄,不过xy忘记怎么弄了。

def number = 0
new File(‘Test.groovy').eachLine{line->
number++
println "$number: $line"
}


第二个是输出package名字的程序,很神奇的程序。外面的brace(括号)不可去。

println ([String, List, File].'package'.name)


页面43
Groovy, the brand-new language for the Java platform, brings to Java many of the features that have made Ruby popular. Groovy in Action is a comprehensive guide to Groovy programming, introducing Java developers to the new dynamic features that Groovy provides. To bring you Groovy in Action, Manning again went to the source by working with a team of expert authors including both members and the Manager of the Groovy Project team. The result is the true definitive guide to the new Groovy language., Groovy in Action introduces Groovy by example, presenting lots of reusable code while explaining the underlying concepts. Java developers new to Groovy find a smooth transition into the dynamic programming world. Groovy experts gain a solid reference that challenges them to explore Groovy deeply and creatively., Because Groovy is so new, most readers will be learning it from scratch. Groovy in Action quickly moves through the Groovy basics, including:, # Simple and collective Groovy data types, # Working with Closures and Groovy Control Structures, # Dynamic Object Orientation, Groovy style, Readers are presented with rich and detailed examples illustrating Groovy's enhancements to Java, including, # How to Work with Builders and the GDK, # Database programming with Groovy, Groovy in Action then demonstrates how to Integrate Groovy with XML, and provides,, # Tips and Tricks, # Unit Testing and Build Support, # Groovy on Windows, An additional bonus is a chapter dedicated to Grails, the Groovy Web Application Framework.
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值