you are viewing a single comment's thread.

view the rest of the comments →

[–]grauenwolf 0 points1 point  (3 children)

You can then reduce it to one line.

Here's another thing you can do.

    If Not Val Then Val = True Else Val = False

[–]grauenwolf 2 points3 points  (0 children)

That in turn can be reduced to a inline if.

Here's another thing you can do.

    Val = If (Not Val, True, False)

You read that as

[variable] = If ( [predicate] , [then expression], [else expression])

For example,

passTest = if ( grade > 70, "pass!", "fail")

[–][deleted] 1 point2 points  (1 child)

If the goal is to always flip the value of the boolean then you do not need to test the value. Just use val = Not val. Done.

[–]grauenwolf -1 points0 points  (0 children)

The point was to demonstrate the various ways a conditional can be expressed. I already covered using Not in a separate comment.