Is Groovy syntax an exact superset of Java syntax?

前端 未结 4 1833
春和景丽
春和景丽 2021-01-01 10:06

Being a Java programmer, I don\'t really have a Groovy background, but I use Groovy a lot lately to extend Maven (using GMaven). So far, I could use all the Java code I need

4条回答
  •  执笔经年
    2021-01-01 10:19

    Others have already given examples of Java syntax that is illegal in Groovy (e.g. literal arrays). It is also worth remembering that some syntax which is legal in both, does not mean the same thing in both languages. For example in Java:

    foo == bar
    

    tests for identity, i.e. do foo and bar both refer to the same object? In Groovy, this tests for object equality, i.e. it returns the result of foo.equals(bar)

提交回复
热议问题