【提案】安全解构运算符(...?) #68
Replies: 1 comment
-
in this case, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
使用扩展运算符
...
解构非可迭代对象会导致 TypeError。引入新的运算符
...?
当应用于非可迭代对象时,将忽略该对象而不是抛出异常。如果
expr
是可迭代的,...?expr
行为与...expr
相同。如果
expr
不可迭代,...?expr
将忽略该对象。这样无需额外检查
expr
是否可迭代,使代码更加简洁清晰。Beta Was this translation helpful? Give feedback.
All reactions