Skip to content

Conversation

haltcase
Copy link

Q A
Bug fix? no
Breaking change? no
New feature? yes
Deprecations? no
Spec compliancy? no
Tests added/pass? yes
Fixed tickets #28
License MIT
obj = { dude: 'sweet' }
for val { dude } in obj:
  console.log(dude)
  // -> 'sweet'
arr = [
  [1, 2, 3]
  [4, 5, 6]
  [7, 8, 9]
]

for elem [x, y, z] in arr:
  console.log(x, y, z)
  // -> 1, 2, 3
  // -> 4, 5, 6
  // -> 7, 8, 9

Bo Lingen added 2 commits April 27, 2017 18:07
Add support for object & array destructuring in `val` and `elem` of enhanced lightscript for-in loops.
Copy link

@rattrayalex rattrayalex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome! You sure ramped up quickly on the parser!

The tests are great, too! Let's add one or two for "complex" destructuring, eg;

for elem { a, b: { c: d }, e = 1 } in arr:

and also an invalid object:

for val { a: 1 } in obj:

this.next();
node[iterType] = this.parseBindingIdentifier();
node[iterType] = iterType === 'elem' || iterType === 'val'
? this.parseBindingAtom()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

Copy link

@rattrayalex rattrayalex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful!! Thanks!

@rattrayalex rattrayalex merged commit b8a2bb9 into lightscript:lightscript Apr 27, 2017
wcjohnson pushed a commit to wcjohnson/babylon-lightscript that referenced this pull request Apr 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants