[Laszlo-dev] new function arguments (e.g. start='either')

André Bargull andre.bargull at udo.edu
Fri Jan 9 10:49:59 PST 2009


Not really...

This testcase prints:
> s was null
and _*not*_
> s was 'null'

<canvas debug="true" oninit="this.meth(null)" >
  <method name="meth" args="s:String" >
    Debug.write("s was %w", s);
  </method>
</canvas>

The only special thing about Strings in AS3, is how `undefined` is handled.
var t:String = undefined; // this will be changed to `null`
var r:String = String(undefined); // this is really `undefined`


> Finally, you can declare the types of your arguments.  These types are  
> ignored in the JS1 back-ends, but they are enforced in JS2 (swf9).
>
>    function foo (required:String, optional:Boolean=false)
>
> Caution:  You will get a type error, but _only_ if there is not a  
> coercion available.  Hence, passing `null` as the first argument to  
> foo above will cause it to be called with the string "null", not the  
> null value.  If you want a nullable type, you should leave the type  
> undeclared (for now...).
>   


More information about the Laszlo-dev mailing list