Apply method with curly braces

前端 未结 2 1392
感动是毒
感动是毒 2021-01-15 03:05

Why this works:

  List(
   \"string\", \"string2\"
  )

But this doesn\'t?

  List{
   \"string\", \"string2\"
  }

2条回答
  •  孤街浪徒
    2021-01-15 03:49

    The difference is in the comma -- you can only have a comma separated argument list when using parentheses.

    You will find that

    List {
        3
    }
    

    works just fine.

提交回复
热议问题