+ 3

Can 1 method return 2 answers?

10th Feb 2018, 12:37 AM
mateo quiceno toro
mateo quiceno toro - avatar
4 odpowiedzi
+ 7
You can return an array to return multiple values, if that's what you're after. Also possible to use if-then style or switch to change return value based on input.
10th Feb 2018, 1:07 AM
Tom Shaver
Tom Shaver - avatar
+ 3
It depends on the language. In some languages you can also return "tuples". If the language doesn't support tuples you can create your own class with the multiple values you want returned. Another alternative is passing values by reference.
10th Feb 2018, 1:38 AM
Jesse Bayliss
Jesse Bayliss - avatar
+ 2
Thanks brother, that's what I was researching
10th Feb 2018, 1:12 AM
mateo quiceno toro
mateo quiceno toro - avatar
0
No problem mateo, and thank you Jayden.
10th Feb 2018, 2:17 AM
Tom Shaver
Tom Shaver - avatar