• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to assign a return method's value to two variables  RSS feed

 
Hai-Tan Le
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all, I am looking for an easy way to assign a return method's value to two variables.
Right now, I have it written out in a long way. I hope someone could give me a quicker way. Thanks

Here is what I am currently using:

 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you mean by "quicker". The only way I can think of to possibly do it would be something like

but personally, I find this code to be VERY ugly, and would tell anyone under me to write it the way you did originally.

note: I fixed your post - you had the code tags, but your code was not between them, it was after both.
 
Rob Spoor
Sheriff
Posts: 21095
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

I would definitely prefer the original code over the "assign-then-use-its-value" code Fred posted.
 
Campbell Ritchie
Marshal
Posts: 55774
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fred did describe it as "VERY ugly".
 
Hai-Tan Le
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!