You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
参考C#object-creation-expressions 如何使用对象初始值设定项初始化对象
由于MC中选择器语法例如
@e[type=player]
这样,如果把选择器语法的中括号形式和new域操作结合起来,可以将字面量@e
视为即将初始化一个选择器对象,而中括号内容为更改初始化属性。在这种设计下,大括号-冒号的组合专注于字典字面量,中括号-等号的组合专注于new域操作。例如
@e[score={foo=1..2}]
应写作@e[score={foo: 1..2}]
以消歧义。此外,对于nbt来说,如果支持函数单参数调用去括号,则可以写作
nbt {name:"test"}
,对于json来说,则写作json {"name":"test"}
。这样形式更为统一。这种设计下,似乎可以给字面量进行域操作,例如
int i= 1[name=temp]
这样(虽然可能不是很好看)。Beta Was this translation helpful? Give feedback.
All reactions