From: Paul Lutus Date: 2006-11-11T10:25:05+09:00 Subject: Re: Beginner question: testing for either condition? Taylor Strait wrote: > I want to check two conditions. If EITHER of them are true I want to > proceed. Unfortunately what I have is returning true no matter what: > > if (@unit.custodian_id == session[:person_id]) or (session[:person_role] > == 'admin') In English: IF A=TRUE OR B=TRUE THEN ACT Yes? Is this what you want? If not, offer a better explanation. But let's assume yes. In Ruby (note the change): if (@unit.custodian_id == session[:person_id] || session[:person_role] == 'admin') # do something here end > > How can I test for EITHER condition without repeating myeself? Is my > only solution to use elsif? Avoid using a mixture of "&&, ||" and "and, or". They have different orders of precedence. I prefer &&, ||, but that is a personal taste issue. -- Paul Lutus http://www.arachnoid.com