0 Replies - 7797 Views - Last Post: 27 September 2010 - 10:33 AM

#1 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10596
  • View blog
  • Posts: 39,257
  • Joined: 27-December 08

Week #33- Groovy

Post icon  Posted 27 September 2010 - 10:33 AM

This week's challenge is Groovy!
Posted Image

Groovy is a dynamic scripting language that runs on the Java platform with very similar syntax to Java, along with a number of dynamic features. In fact, most Java syntax is valid Groovy syntax. However, Groovy code can be more compact than Java because it doesn't require many of the elements that Java does. For example (source: Wikipedia), this segment in Java:
for (String it : new String[] {"Rod", "Carlos", "Chris"})
     if (it.length() <= 4)
         System.out.println(it);



Can be written as in Groovy.
["Rod", "Carlos", "Chris"].findAll{it.size() <= 4}.each{println it}



Some of Groovy's features include:
  • Dynamic typing with the def keyword
  • Closures
  • Operator Overloading
  • Native syntax for lists and associative arrays
  • Native Support for RegEx
  • Polymorphic Iterations
  • The ?. operator to auto-check for nulls


Getting Started and Resources:
The Groovy Website
Eclipse Plugin
NetBeans Plugin

Is This A Good Question/Topic? 0
  • +

Page 1 of 1