Robert Klemme
8/16/2006 1:46:00 PM
On 16.08.2006 15:42, Brad Tilley wrote:
> What's the best way to check if a string is not exactly what you're
> expecting? I'm doing this:
>
> b = 'brad'
> if not b.eql?('bradsdhsh')
> puts 'not equal'
> else
> puts 'equal'
> end
>
> Is there a more proper way to do it?
KISS:
b = 'brad'
if 'bradsdhsh' == b
puts 'equal'
else
puts 'not equal'
end
Or, as a one liner
puts 'bradsdhsh' == b ? 'equal' : 'not equal'
HTH
robert