Friday, January 22, 2010

Groovy Rules - Step 15

Here are some important Groovy Rules that you should know:

if(1) = true because any non-zero value is true
if(-1) = true
if (!null) = true because any non-null value is true
if("John") = true because any non-empty string is true
Map family="[dad:"John"]
if (family) = true since the map is populated
String [] sa = new String[1]
if(sa) = true since the array length is greater than 0

I think you get the picture. This is based on common sense. If the class isn't null, has items in the list, and isn't empty, it will return true.

0 comments: