I believe it's called, 'short-circuit evaluation', and applies to binary operators like AND and OR. i.e. If you have two expressions that evaluate to the Boolean data type, and you're using them like

If <expr1> AND <expr2> Then

the computer will check <expr1> first and - if false - won't bother to check <expr2>. This is handy if <expr2> involves an object reference, then <expr1> can test for the reference <> nil, thus saving you from a NilObjectException in <expr2>! i.e.

If (myObj <> nil) And myObj.CanPerform(someTask) Then
  myObj.PerformTask(someTask)
End If

as an example.

On Feb 14, 2007, at 9:23 PM, Sam DeVore wrote:

So in some languages you can test a number of things and if it fails it doesn't test the others is this true in RB?

so like

if x<> nil and x.isEqualTo( y) then
   bla bla
else
  alert "x is nil"
end if

so if x is nil it jumps right to the else


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to