object literal types

David-Sarah Hopwood david.hopwood at industrial-designers.co.uk
Tue Feb 17 03:20:41 PST 2009


Michael Haufe wrote:
>> var Point:object = {
>>    color:string
>>    x:double = 20,
>>    y:double = 50,
>>    z:double = 3
>> }
> -----------------------------------------------------------------------------------------
> 
> Sorry, typo correction:
> 
> var Point:object = {
>    color:string = "red",
>    x:double = 20,
>    y:double = 50,
>    z:double = 3
> }

':' (not '=') is used to separate a property name from its value, so it
can't also be used for type annotations. This example would have to be
something like:

var Point = {
  color @string: "red",
  x @double: 20,
  y @double: 50,
  z @double: 3,
};

-- 
David-Sarah Hopwood ⚥



More information about the Es-discuss mailing list