Allow to change variables names in destructuring assignements
Closed this issue · 1 comments
tanguylebarzic commented
Allow to change the names of the variables that are assigned in a destructuring assignement. as could be used as a keyword for this.
This would for example allow this:
{error as error1, result as result1} = function1()
{error as error2, result as result2} = function2()
doSomething(result1, result2)
instead of:
{error, result} = function1()
error1 = error
result1 = result
{error as error2, result as result2} = function2()
error2 = error
result2 = result
doSomething(result1, result2)
or
temp1 = function1()
error1 = temp1.error
result1 = temp1.result
temp2 = function2()
error2 = temp2.error
result2 = temp2.result
doSomething(result1, result2)
This is especially useful when function1 or function2 are provided by third parties, whose names may not fit into the rest of the program. as seems a good fit, as it's very similar to SQL syntax that many programmers know, eg. (SELECT GithubIssue.name AS issueName FROM GithubIssue)
What do you think?
vendethiel commented
Just do
{error: error1, result: result1} = function1()