Short-circuit evaluation: Difference between revisions
Content deleted Content added
Line 938: | Line 938: | ||
return v |
return v |
||
} |
} |
||
func b(v) { |
func b(v) { |
||
print(nameof(b), terminator: "") |
print(nameof(b), terminator: "") |
||
return v |
return v |
||
} |
} |
||
func |
func testMe(i, j) { |
||
print("Testing a(\(i)) && b(\(j))") |
print("Testing a(\(i)) && b(\(j))") |
||
print("Trace: ", terminator: "") |
print("Trace: ", terminator: "") |
||
print("\nResult: \(a(i) && b(j))") |
print("\nResult: \(a(i) && b(j))") |
||
print("Testing a(\(i)) || b(\(j))") |
print("Testing a(\(i)) || b(\(j))") |
||
print("Trace: ", terminator: "") |
print("Trace: ", terminator: "") |
||
print("\nResult: \(a(i) || b(j))") |
print("\nResult: \(a(i) || b(j))") |
||
print() |
print() |
||
} |
} |
||
testMe(false, false) |
|||
testMe(false, true) |
|||
testMe(true, false) |
|||
testMe(true, true)</lang> |
|||
{{out}} |
{{out}} |