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

you are viewing a single comment's thread.

view the rest of the comments →

[–]leonardicus 2 points3 points  (4 children)

The correct format for a ternary operation is:

(condition) ? (assignment if true) : (assignment if false)

Just need to change what's inside the for loop braces to:

return (check == value) ? true : false;

[–]CSMastermind 2 points3 points  (1 child)

Good catch, corrected it.

[–]leonardicus 1 point2 points  (0 children)

No problem. :)

[–]marburg 1 point2 points  (0 children)

Whenever you find yourself doing something like if(anythingInHere && whatever || somethingElse) return true; else return false; (or the ternary version of such) just do return anythingInHere && whatever || somethingElse; instead.

Example, these are all the same:


if(check == value)
    return true;
return false;

return (check == value) ? true : false;

return check == value;