Thursday, April 8, 2010

Difference between "and" and "&&"

klasses = ['last'] && txt = '' if idx == (tabs.length - 1)


At the end of this statement klasses will contain "".

klasses = ['last'] and txt = '' if idx == (tabs.length - 1)


At the end of this statement klasses will contain ['last'] which was what I intended. But the first statement wasn't returning that.

A good explanation is here http://stackoverflow.com/questions/1426826/difference-between-and-and-in-ruby