-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update loop syntax for arrays and objects, deprecate $index and $key #3073
Comments
How would this be supported in |
@simplesmiler as of now I don't think it's feasible to provide a "seamless" migration build like the 0.12 to 1.0 upgrade, due to how much underlying implementations have changed. The deprecation warnings will mostly be used for features that can be simulated. |
@yyx990803 This is how it will work:
It certainly does not look like elegant but I prefer it over no seamless-migration build. I don't what other problems which you are facing. But I am certain that seamless migration is possible with some workarounds which many will find acceptable. |
@prog-rajkamal hmm, that's a good idea. Toggle between incompatible interfaces using flags would definitely make a migration build more feasible. |
Deprecating
$index
and$key
Both of these are being deprecated in favor of more explicit named indices and keys. This syntax is a bit magical and has limitations in nested loops. As a bonus, there will be two fewer points of syntax for newcomers to learn.
New array syntax
value in arr
(value, index) in arr
(switched order of arguments to be more consistent with JavaScript'sforEach
andmap
)New object syntax
value in obj
(value, key) in obj
(switched order of arguments, partly to be more consistent with many common object iterators, such as lodash's)(value, key, index) in obj
(index will now be available in object iteration for visual purposes, such as table striping)The text was updated successfully, but these errors were encountered: