Bear Bibeault wrote:You can't. Think about it: does that really make sense?
If you have multiple related values that should be treated as a unit, define a class to encompass them. You can return an instance of that class.
Rico Felix wrote:Something along the lines of:
Bear Bibeault wrote:You can't. Think about it: does that really make sense?
OCAJP Java 8, OCPJP Java 8
Mike. J. Thompson wrote:
Bear Bibeault wrote:You can't. Think about it: does that really make sense?
I wouldn't say that the concept of returning multiple variables doesn't make sense, its just something that Java doesn't allow. Other languages do allow it, so maybe OP has experience of those? I'm working on a C++ project that also uses Python at the minute, and both of those support the concept of Tuples. I will probably miss the ability to do that when I go back to Java.
Mike. J. Thompson wrote:I wouldn't say that the concept of returning multiple variables doesn't make sense, its just something that Java doesn't allow. Other languages do allow it, so maybe OP has experience of those? I'm working on a C++ project that also uses Python at the minute, and both of those support the concept of Tuples.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Dave Tolls wrote:On the other hand, I started in Ada and I did miss the whole IN, OUT and IN/OUT parameters for a while.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Dave Tolls wrote:On the other hand, I started in Ada and I did miss the whole IN, OUT and IN/OUT parameters for a while.
I was a Progress programmer for quite a while, and it has the same idea. Didn't know it came from Ada though.
Winston
Winston Gutkowski wrote:
But wouldn't a Tuple be an object of some kind? What C++ has, since it's an extension of C, is a struct, which sounds a bit closer to what John wants.
Winston Gutkowski wrote:
However, in my experience, a function that needs to return multiple values almost always has a reason for doing so; and that's usually because they represent either:
1. An array or collection of some sort.
2. Some other object used in the system.
Jesper de Jong wrote:You could do that by returning an array, which is an ugly way to solve it...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |