Destructure into object context
Closed this issue · 2 comments
Something like this would be very useful:
(From destructuring example in docs)
object[poet: {name, address: [street, city]}] = futurists
or maybe
object = {poet: {name, address: [street, city]}} = futurists
and
object.name is now "F.T. Marinetti"
Destructuring is about extracting data from an object into variables -- doing an object merge isn't really the goal of the feature, as you'd have to support arrays as well. Better to use two lines to do it.
This is also about extracting data from an object into variables, but the destination is under the context of an object. It's not a merge so much as a restructure, since the destination is created on request. Destructuring currently seems frustratingly incomplete and suited toward temporary variables, which find less frequent use in my experience.
Would add
object.{poet: {name, address: [street, city]}} = futurists