Miscellaneous

Garrett dhtmlkitchen at gmail.com
Tue Jul 17 00:11:58 PDT 2007


I found this example:

http://www.mozilla.org/js/language/es4/rationale/miscellaneous.html#typed-arrays

================================================================
function chickenCount(myChickens:Array[Chicken]):Integer {
  if (notHatched(myChickens))
    abort("Can’t count the chickens yet");
  else
    return myChickens.length;
}

Note that if the function abort had no explicit return type or any return
type other than Never, then the compiler would likely issue a warning inside
the function chickenCount because it contains a code path (the false case of
its if) that appears to fall out of the function without returning a value,
while chickenCount is declared to return an Integer. The Never return type
on abort tells the compiler that there is no such code path inside
chickenCount.
================================================================

If I'm not mistaken, the description below can only make sense if the
example has "return abort( ... )", not  "abort( ... )".



-- 
View this message in context: http://www.nabble.com/Miscellaneous-tf4095236.html#a11644410
Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at Nabble.com.




More information about the Es4-discuss mailing list