Posts

Showing posts from August, 2016

Groovy Notes

 Groovy is a great mix of dynamic flavor, while still  being able to use types. It is one of few languages  that sport optional typing, that is, the flexibility  to provide type information if we want to and leave  type information aside when we don't want to. Closure in Groovy is a block of code that can be assigned to  a reference or passed around just like any other variable.  The concept is known as lambda in many other languages,  including Java 8 or function pointers. 1.) Hello World program   def cl1 = {      println "hello world!" } cl1.call() it prints the following: hello world! 2.) As closures are like methods, they can also accept parameters: example 1: def cl2 = { n ->     println "value of param : $n" } cl2.call(101) It prints the following: value of param : 101 example 2: 3.times(cl2) It prints the following: value of param : 0 value of param : 1 value of param : 2 We can also inline the block a...