Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about a nitpick

 
Tony VanHorn
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am struggling seeing this from a different perspective. I have a section of code that executes atleast once, but maybe twice and thats all. The two ways I have thought of this is:


or

So, anyone with another idea of how to handle this without a loop or repeated code? Any "hint" in the right direction would be greatly appreciated.
 
Dick Summerfield
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tony VanHorn:
I have a section of code that executes at least once, but maybe twice and thats all.


Seems to me your second example does exactly what you want, Tony.
To compare it with what you say above:

So, anyone with another idea of how to handle this without a loop or repeated code? Any "hint" in the right direction would be greatly appreciated.

Not another idea but I seems like the way to go...
 
Tony VanHorn
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah, so that was the way to go, the issue i had was my line of code was too long to repeat twice. I found in another thread that pulling that line of code into a method and then just calling the method twice would be a better choice. Thanks for the input.

Tony
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic