More concise syntax for accepting multiple return values

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is ON
[img] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: More concise syntax for accepting multiple return values

More concise syntax for accepting multiple return values

by argv » Fri Jun 29, 2018 10:19 pm

Currently, in order to receive multiple return values, one must separately declare the variables (without type inference), then call the method and assign the return values to the variables.

It would be preferable to be able to do this with a single ‘let’ statement, like with single return values:

Code: Select all

let [number, another, success] = MyFunction(1, 2);
It would also be preferable to be able to discard some of the return values, without assigning them to variables:

Code: Select all

int b;
[_, b] = MyFunction(1, 2);

Top