所有语句都可以在``列表''中执行的内容,例如[if(true),for(;;)]``

发布于 2025-02-06 23:15:35 字数 180 浏览 1 评论 0原文

我知道, loops, if(true)条件和三元运算符((true)?1:2) ,但

我很好奇,所有语句都可以在list initialization [] 中执行,例如[if(true),for(;;) ]

感谢您...

I know of, for(;;) loops, if(true) conditions, and ternary operators ((true)?1:2), but

I'm curious, that what all statements can be executed inside the List initialization [], like [ if(true), for(;;) ],

Thanking you...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

櫻之舞 2025-02-13 23:15:35

特别感谢您通过评论提供的回答,并谦虚地@jamesdlin。

所有表达式都得到支持,例如:

  1. for loops:for(;;)
  2. 如果条件:if(true)
  3. ternary operator:(true)?1:2
  4. 传播操作员:... ['1','2','3']
  5. (x + y)
  6. <代码>函数(参数)

来源

Special thanks to the ever helping and humble @jamesdlin for this answer via comment.

All the expressions are supported, like:

  1. for loops: for(;;)
  2. if condition: if(true)
  3. ternary operator: (true)?1:2
  4. spread operator: ...['1', '2', '3']
  5. (x + y)
  6. function(argument)

etc.

source

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文