S
swille
I have a couple of standard programming questions. The first is that
I often like to return true or false in a method when no other return
value is really needed. Is that bad form? I was talking to someone
the other day who said said something that made me think that maybe it
was. For example:
def login()
rc =3D false
begin
perform action
rescue
rc =3D false
some error
end
return rc
end
I like that because it reads well when you use it
if login
do_stuff
else
complain
end
My second question is this. I occasionally see stuff like
if -1 =3D=3D result
rather than
if result =3D=3D -1
What, if any, is the benefit of one over the other?
Thanks
I often like to return true or false in a method when no other return
value is really needed. Is that bad form? I was talking to someone
the other day who said said something that made me think that maybe it
was. For example:
def login()
rc =3D false
begin
perform action
rescue
rc =3D false
some error
end
return rc
end
I like that because it reads well when you use it
if login
do_stuff
else
complain
end
My second question is this. I occasionally see stuff like
if -1 =3D=3D result
rather than
if result =3D=3D -1
What, if any, is the benefit of one over the other?
Thanks