Can you create a MyClass.groovy file that contains a MyClass within?

I have been reading the forums and can't find a definitive answer on this one. It seems when I do have .groovy files that are also groovy classes of the same name (like Java) I evetually
start getting a red inspector line that the class already exists. I've been careful  to exclude output and target folders but still get this annoting line. I'm trying to get my team to adopt Groovy and this is not building confidence. It does not prevent compilation/building however. If the common convention is to name the class differently than the file, I'll go ahead and do that.

0

>Can you create a MyClass.groovy file that contains a MyClass within?

Yes. But the file MyClass.groovy must contain only classes.
If MyClass.groovy contains a script, Groovy creates a synthetic class
MyClass for this script. Because of it your own MyClass will conflict with
the synthetic one.

--
Maxim Medvedev
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"

0

请先登录再写评论。