Something fun with Groovy's 'HERE DOCUMENT', i.e., """..."""
In groovyConsole, execute (Ctrl + R) following code:
"""
${ println "Hi" }
"""
result: Hi
Cool, isn't it?
How about this?
"""
${
class Foo{}
}
"""
No way...Why?
The curly braces denote a
closure, So, we can put
anything valid in a closure into the ${} within a HERE DOC:
a = [1,2,3,4,5,6]
"""
${
a.each {print it}
}
"""
result: 123456
Wow, closure within closure. So below is nothing strange:
"""
${
println """ ${println "Can you see me?"} """
}
"""
result: yes, I can :)
分享到:
- 2007-05-09 19:45
- 浏览 1670
- 评论(1)
- 论坛回复 / 浏览 (1 / 2439)
- 查看更多
相关推荐
Groovy and Grails Recipes.pdf ebook
With relevant examples, careful explanations of Groovy's key concepts and features, and insightful coverage of how to use Groovy in-production tasks, including building new applications, integration ...
You'll see how to harness Gradle (Groovy's build system), Grails (Groovy's web application framework), Spock (Groovy's testing framework), and Ratpack (Groovy's reactive web library). What You Will ...
Groovy and Grails Recipes 作者:Bashar Abdul-Jawad 共407页 PART 1 Groovy by Example CHAPTER 1 Getting Started with Groovy CHAPTER 2 From Java to Groovy CHAPTER 3 Groovy Data Types and Control ...
You’ll see how to harness Gradle (Groovy’s build system), Grails (Groovy’s web application framework), Spock (Groovy’s testing framework), and Ratpack (Groovy’s reactive web library). ...
Apress - Beginning Groovy and Grails, From Novice to Professional.pdf
begining groovy and grails
Making Java Groovy is a practical handbook for developers who want to blend Groovy into their day to day work with Java It starts by introducing the key differences between Java and Groovy and how you...
Beginning_Groovy_and_Grails_From_Novice_to_Professional开源项目教学代码配合Beginning_Groovy_and_Grails教材使用全是原代码开源。由于上传限制分8个部分
groovy document for second Programming Groovy 2
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 ...
Not only did Groovy and its environment change, we authors changed as well. We enjoyed the luxury of working on Groovy projects, introducing new team members to the language, running workshops and ...
Making Java Groovy Kenneth A. Kousen 1.Easier Java 2.Closures, builders, and metaprogramming 3.Gradle for builds, Spock for testing 4.Groovy frameworks like Grails and Griffon 源码
apache-groovy-3.0.8.zip apache官网的groovy3.0.8版本,希望大家多多下载,apache-groovy-3.0.8.zip apache官网的groovy3.0.8版本,希望大家多多下载,apache-groovy-3.0.8.zip apache官网的groovy3.0.8版本,希望...
groovy入门经典,groovyeclipse 插件
赠送jar包:groovy-3.0.9.jar; 赠送原API文档:groovy-3.0.9-javadoc.jar; 赠送源代码:groovy-3.0.9-sources.jar; 赠送Maven依赖信息文件:groovy-3.0.9.pom; 包含翻译后的API文档:groovy-3.0.9-javadoc-API...
Groovy
groovy
Java调用Groovy,实时动态加载数据库groovy脚本,java读取mongoDB的groovy脚本,加载实时运行,热部署