jastrachan | 1 Apr 19:18 2005
Picon

Re: Interesting feature: Lists coerced into Constructors


On 1 Apr 2005, at 17:01, phkim@... wrote:

>> And if you use the deprecated constructor of Date:
>>
>> Date d = [77, Calendar.JUNE, 28]
>> println d
>>
>> Will print: Tue Jun 28 00:00:00 CEST 1977
>
> Date d = []
> println d     // Output is the current datetime.
> d = []
> println d     // Output is [].
>
>
> Why does the second output differ from the first?

The first coerces the right hand side to be a type of 'Date'

So
     Point p = [1, 2]

is equivalent to
     def p = [1, 2] as Point

James
-------
http://radio.weblogs.com/0112098/


Gmane