[thelist] JS Boolean Object...

jsWalter jsWalter at torres.ws
Thu Dec 4 19:10:55 CST 2003


> > -----Original Message-----
> > From: thelist-bounces at lists.evolt.org
> > [mailto:thelist-bounces at lists.evolt.org]On Behalf Of James Aylard
> > Sent: Thursday, December 04, 2003 3:24 PM
> > To: thelist at lists.evolt.org
> > Subject: Re: [thelist] JS Boolean Object...
>
> > Have someFunc return a Boolean value, either true or false (or
> > else a value than can be evaluated to either true or false [1]):
> >
> > function someFunc(myVar)
> > {
> >   if ("Blue" == myVar)
> >   {
> >     return true ;
> >   }
> >   return false ;
> > }

BTW: After reading this message again, it finally hit me, you have 2 exit
points in your function.

Me, I'm a stickler for the old mind set - "One way in - one way out"

    function someFunc(myVar)
    {
      bolVal = true ;

      if ("Blue" == myVar)
        return true ;

      return bolVal ;
    }

To me, this makes it very clear and easy to debug (well, this is a very
simple example) when I know there is only one way out this function.

So, if I'm not getting back what I think I should be, I don't have to trace
multiple exit points.

But then again, that's me. Many people have commented to me about my
defining default values for variables that are returned and then setting
them as I need to and then exiting only at the end.

I'm just quirky that way!

;)

Walter




More information about the thelist mailing list