• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

favorite groovy idiom

 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Our local user group had a talk on Groovy this evening. One of the things the speaker mentioned was that some new Java programmers write "Java in Groovy" rather than using Groovy idioms.

Does anyone who has used Groovy have an example of something they wish people would do the groovy way?
 
Author
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two things jump to mind:

I really like the .each{} language feature. You can iterate over almost everything with .each, and where I can't I end up using metaprogramming to add an .each closure myself... (grin)




The other idiom / language feature I really like is shortening the "getter/setter" call to the field name. You are truly calling the getter/setter behind the scenes, but it cuts down on an _amazing_ amount of visual clutter:

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Though my favorite idiom (using each) has already been mentioned by Scott; I also enjoy the following idiom when working with maps.

 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cool. Thanks guys.
reply
    Bookmark Topic Watch Topic
  • New Topic