Ross Bamford
6/14/2006 3:49:00 PM
On Wed, 14 Jun 2006 15:27:05 +0100, dave <BITDOGER@YAHOO.COM> wrote:
> can't find the correct standalone comparator object for not
> equals....in irb
> g=3D'give'
> g.>('a') >>true
> g.<('h') >>true
> g.=3D=3D('give') >>true
> ....how does one DO not equals because g.<>('able') >>irb error OR
> g.!=3D('able') >>irb error
>
> ....also do not understand why:
> at_hotel=3Dtrue
> if at_hotel puts 'hi' end >>> gives a irb syntax error
> ...BUT.....
> if at_hotel
> puts 'hi'
> end >>>is oka in irb????
>
# Don't use dots, especially not for !=3D which isn't even a method
g =3D 'give'
# =3D> "give"
if g !=3D 'able' then "Not equal" end
# =3D> "Not equal"
# Alternatively, if can be used as a statement modifier ...
"Not equal" if g !=3D 'able'
# =3D> "Not equal"
"Not equal" unless g =3D=3D 'able'
# =3D> "Not equal"
-- =
Ross Bamford - rosco@roscopeco.remove.co.uk