Groovy Joe Ice Cream & Dinosaurs

What is Grails? Grails (previously known as "Groovy on Grails") is a programming framework based on Groovy and inspired by Ruby on Rails (there are differences, but there are lots of similarities too). Like RoR, Grails promotes "coding by convention", development best practices, and is meant to be highly productive.

Groovy Joe Ice Cream & Dinosaurs 1

What is the "?:" operator used for in Groovy? - Stack Overflow

Groovy Joe Ice Cream & Dinosaurs 2

I use it all the time. EDIT: Just looking at it they are slightly different--split returns an array while tokenize returns an ArrayList. Virtually the same thing in Groovy, the split has the advantage that it ports easily to Java, I don't think tokenize is a java method on String (unless it's a fairly new one and I missed it)

Groovy Joe Ice Cream & Dinosaurs 3

In Groovy you also have to be aware that in addition to ==, alias "Match operator", there is also =, alias "Find Operator" and ~, alias "Pattern operator". All are explained here.

In groovy, the bitwise operators can be overridden with the leftShift (<<) and rightShift (>>) methods defined on the class. It's idiomatic groovy to use the leftShift method for append actions on strings, buffers, streams, arrays, etc and thats what you're seeing here.

Groovy Joe Ice Cream & Dinosaurs 5

In Groovy, null == null gets a true. At runtime, you won't know what happened. In Java, == is comparing two references. This is a cause of big confusion in basic programming, Whether it is safe to use equals. At runtime, a null.equals will give an exception. You've got a chance to know what went wrong. Especially, you get two values from keys not exist in map (s), == makes them equal.

Groovy Joe Ice Cream & Dinosaurs 6