Fortunately, I've seen Ruby and Java,groovy feel a bit like them before.
And I think this groovy is simpler than Scala (functional programming +obj)
The fastest way to learn is to make an analogy.
XXX, there are compulsory courses and securities from the staff qualification examination, this period is a bit full of ha,,
Tomorrow night with the basketball brothers drinking, and "hacker Corps" to follow up ...
Practice a groovy code, three days without learning, can't keep up with Liu Shaoqi!!!
def message = 12println Messagedef Repeat (Val, repeat= 5){ for(i in 0..) <repeat) {println val}} Repeat ("Hello World") Repeat ("Goodbye Sunshine", 4) def Range= 0.. 4println range.classassertRangeinstanceofListdef Coll= ["Groovy", "Java", "Ruby", "Python"]assertCollinstanceofCollectionassertCollinstanceofArraylistcoll.add ("Perl") Coll<< "Smalltalk"coll[6] = "Ada"assertCOLL[1] = = "Java"def numbers= [1, 2, 3, 4]assertNumbers + 5 = = [1, 2, 3, 4, 5]assertNumbers-[2, 3] = = [1, 4] assertNumbers.join (",") = = "1,2,3,4"assert[1, 2, 3, 4, 3].count (3) = = 2assert["JAVA", "GROOVY"] = = ["Java", "Groovy"]*. toUpperCase () def Hash= [Name: "Andy", "vpn-#": 45]assertHash.getclass () = =Java.util.LinkedHashMap//hash.put (ID,%)assertHash.get ("name") = = "Andy"Hash.dob= "01/29/76"assertHash.dob = = "01/29/76"def Acoll= ["Groovy", "Java", "Ruby"] for(Iterator iter =acoll.iterator (); Iter.hasnext ();) {println iter.next ()}acoll.each{value-//println Itprintln Value}hash.each {key, value-println"${key}": "${value}"}"Iteration". each{print it.tolowercase ()}def excite= {Word->return"${word}!!"}assert"groovy!!" = = Excite ("Groovy")
Output diagram:
Groovy learns to mingle with Grails,rundeck
.