Global constants in Groovy

前端 未结 4 1121
名媛妹妹
名媛妹妹 2021-01-31 14:17

It is often desired to declare constants at the top of a script that can be referenced anywhere else in the script. In Groovy, it seems that if you declare a constant using fin

4条回答
  •  面向向阳花
    2021-01-31 14:30

    I personally wouldn't do it but technically you could do

    Object.metaclass.MYCONSTANT = 'foobar'

    Then every object has it

提交回复
热议问题