What does [:] mean in groovy?

后端 未结 3 1702
我在风中等你
我在风中等你 2021-01-03 18:44

While reading some groovy code of another developer I encountered the following definition:

def foo=[:]

What does it mean?

3条回答
  •  离开以前
    2021-01-03 19:25

    [:] is shorthand notation for creating a Map.

    You can also add keys and values to it:

    def foo = [bar: 'baz']
    

提交回复
热议问题