Friday, June 10, 2011

semi-colon: ';'

I'm not going to start with the usual "Hello, world!" example.
My beginning is more trivial than that: just a semi-colon.


Every Java statement has to end with ;.
In Groovy, I don't have to. I could, but I don't.
So, this works:

System.out.println("Look, no semicolon!")

It's a small change, but if you get used to it, it can also deter you from trying to put multiple statements in one line as you *might* have been doing in Java.
Don't try to be too clever and try to have multiple statements in one line. It doesn't always help.

No comments:

Post a Comment