Iteration:def names = ["Sky", "Lily", "Tom"]names.foreach {println it.touppercase ()}map = [' A ': 1, ' B ': 2]map.each {key, value-GT Map[key] = value * 2}assert map = = [' A ': 2, ' B ': 4]//result Skylilytom trueCallbackdef Houston (Closure doit) {(10..1). Each {count--, doit (count)}}houston {println It}Higher order functionsSpecial Control logicDynamic method definitionResource allocationThread handlingThis article is from the "Java Small Novices" blog, be sure to keep this source http://le
Package Ch5numbers = [11, 12, 13, 14]def stafftel = [' Ken ': 2745, ' John ': 2746, ' Jessie ': 2772]println ("Numbers:${numbers}")//the contents of the double quotation mark will be interpretedprintln (' Staff Telephone:${stafftel} ')//the contents of the single quotation mark will not be interpretedprintf (' My name is Ken ', [])printf (' My name is ken\n ', [])def a = 10def b = 15printf ("The sum of%d and%d is%d \ n", [A, B, a + b])def x = 1.234Def y = 56.78printf ('%f from%f gives%f \ n ', [
,// program End Timer also ends automatically), note that There is also a timer class in the javax.swing// package, if you use the Swing package in import,// you should pay attention to the name conflict. timertasktask=newtimertask () {publicvoidrun () { ...//the code that needs to be executed every time you put it in here. }};//The following are several ways to schedule a task: timer.schedule (task,time);// Time is a date type: Executed once at the specified times. timer.schedule (task,firsttim
Groovy in Action (Chinese version) page 136th clearly states that this of closure points to closure itself. The author also understands this from the code comment:
Class mother {Int field = 1Int Foo (){Return 2}
Closure birth (PARAM ){Def local = 3Def closure = {caller->[This,Field,Foo (),Local,Param,Caller,This. Owner]}Return Closure}}
Mother Julia = new mother ()
Closure = Julia. Birth (4)Context = closure. Call (this)Println context [0]. Class. Nam
1. SVN code pulling
2. Change pom to the current version.
3. In STS, import is maven project, and version is selected for advanced (you do not need to:. project name is the current version)
4. Errors returned when groovy is canceled
Properties> java build path> Source TAB> included \ excluded remove
5. Cancel js Error Reporting
Properties> java build path> Source TAB> included \ excluded remove
Properties> builders> js validater
Delete the js
Suspected title partyThis article does not involve steps, conditions, loops, spilts, joins, and roles in a workflow.Workflow is not involved.
To put it bluntly, add script control to the responsibility chain.
Extended from Apache common chain:Http://commons.apache.org/chain/
For example, the following chain describes my work day life: breakfast, go to company, work, lunch, work, go home
If it is a holiday, my life may be like this: breakfast, going out high, going home
Now I have a requirement
+ = Outputparams; result + = Outputreturntype; result + = Outputauthor; Result + = outPutdatetime;} else if (jsmethodname) {result + = Outputjsmethodname; result + = Outputdesc; result + = Outputjsparams; result + = Outputjsreturntype; result + = Outputauthor; result + = Outputdatetime;} else {result + = Outputprojectname; result + = Outputpackagename; result + = Outputclass; result + = Outputdesc; result + = Outputauthor; result + = Outputdatetime; res
In the Java language programming, the non null Judgment of object is an eternal topic. For example, we often need to judge a string as follows:
if(str!=null!str.equals("")) { ...... }
Typing such a statement really makes you sick, and sometimes you forget the "!" in the input "!str.equals" statement. Causes the code to have a logical error.
and agile Groovy language development does not require us to worry about such problems. The same judgme
The conversion between strings and numbers is a problem that we are bound to encounter in our project because the value of the variable we get from the user interface is definitely a string.
So, what we often have to do in the project is: first, you need to check the user's input to determine whether the user's input is a number; second, if so, we need to further convert it to numbers to facilitate our calculations.
In the Java language, we want to determine whether a string is a number, there
In the groovy language, Gpath may be one of our most common functions. Of course, we use gpath mostly for operations on Groovybean objects. In fact, in addition to manipulating Groovybean objects, Gpath is also used to manipulate XML documents. Even if it is used for the operation of the Groovybean object, we may not know the use of Gpath very detailed, so we will go into detail to say gpath.
First, Gpath is used to manipulate the properties of a cla
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.