2011-01-21

The retVal pattern

Don't you just love the retVal pattern? I'm sure you've spotted methods like


function getSalary() {
   var retVal;
   if (sex == 'Male') {
      retVal = 9500;
   } else if (sex == 'Female') {
      retVal = 500;
   }
   return retVal;
}


There's some retVal for you. Once you've spotted a retVal, you're likely to encounter some arrowheads too. If you are one the Knights of A Single Exit Point, you may even like it.


Or you could just zip your dog with its own tail, as in


Prelude> let dog = "dog"
Prelude> zip dog (tail dog)
[('d','o'),('o','g')]

1 comment: