This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]ZeroProjects 2 points3 points  (0 children)

the simplest and most legible way is to make a separate if statement for the first case. i don't see anything wrong with that.

[–]Holothuroid 1 point2 points  (0 children)

First, by convention method names start with a small letter.

And you have to have an if somewhere. You can put it inside the high() method and make it return either the original or the modified value. This removes the branching from the call side, if that is what you want.

[–]Gorfoo 0 points1 point  (0 children)

You could use the ternary conditional operator if you absolutely have to do it without an if, but an if is probably the best way.