IntelliJ highlights the 'foo' variable in gray, and says "assignment is not used". What I want to know is - it is right or not...
If this were java and not groovy, I know it wouldn't be right.
public class Foo
{
public Foo()
{
Foo foo = null; // this 'foo' instance is gray ("assignment not used")
try
{
foo = new Foo()
// ...
}
finally
{
if (foo != null)
foo.release();
}
}
public void release(){}
}