or-operator

Ruby: difference between || and 'or'

It is really hard to google this, because neither || nor 'or' are good words to search for :) I am wondering if there is a difference between the two, or if it is just a matter of preference? ...

Shortcut "or-assignment" (|=) operator in Java

I have a long set of comparisons to do in Java, and I'd like to know if one or more of them come out as true. The string of comparisons was long and difficult to read, so I broke it up for readability, and automatically went to use a shortcut operator |= rather than negativeValue = negativeValue || boolean. boolean negativeValue = false...

Ordering of evaluation using boolean or

So I've got this snippet of code. And it works (It says 1 is non-prime).: n = 1 s = 'prime' for i in range(2, n / 2 + 1): if n == 1 or n % i == 0: s= 'non-' +s break print s My problem is that if I change the fourth line to: if n % i == 0 or n == 1:, it doesn't work (it says 1 is prime.) Why is that? Since I'm us...