Is there any situation where Or is better to use than OrElse?
If not, why don’t they just “upgrade” the internal code?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The only reason to use
Oris when you want bitwise arithmetic, i.e. you want to manipulate the bits in a number:This kind is the only case appropriate for
Or. In all other cases (i.e. when using Boolean logic), useOrElse.Despite their similar names,
OrandOrElseare semantically quite distinct operations which should not be confused with each other. It just so happens to be that the internal representation ofBooleans makes it possible to use bitwiseOrto achieve a similar (but not the same) effect toOrElse. (Old versions of BASIC and VB – before .NET – exploited this relationship by only providing anOroperation, noOrElse.)