http://groovy.dzone.com/articles/groovy-sometimes-you-still
I gave it a read, because I wanted to know all the cases where you had to have a semicolon.
He gives two examples, the first of which he’s wrong about, it works fine in 1.6.5 and I believe it works for anything >= 1.6.
def list = [1,2,3] as List<Integer>
println list
This second one (not the exact same example he used) does need a semicolon
{-> assert true == true }()
{-> assert false == false }()
Should be
{-> assert true == true }();
{-> assert false == false }()
This is only the case if you have two closure calls next to each other with nothing in between.
{-> assert true == true }()
println ""
{-> assert false == false }()
works fine.Are there other times when you need a semicolon at the end of the line (assuming only one statement per line)?
His first example was when you have generics at the end of a line, which is slightly different from your first one above. It was this:
ReplyDeletedef list = [1,2,3] as List<Integer>;
println list
However, the semicolon is not necessary.
Yea, you're right. Copy/paste error. I corrected it.
ReplyDelete