using + type inferencing

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

using + type inferencing

Tarwin Stroh-Spijer
I've got a DateTools2 class like so:

class DateTools2 
{
public static function setTime(d:Date, h:Int)
{
return new Date(d.getFullYear(), d.getMonth(), d.getDate(), h, 0, 0);
}
}

Now if I try and do:

var d = Date.now();
var d2 = d.setTime(1).setTime(2);

It will complain that the second call doesn't exist.

But if I set the return type it's fine ie:

public static function setTime(d:Date, h:Int):Date

Is this correct or should this be inferencing? Is there a lack of some kind of "deep inferencing" when having "using" ?


Tarwin Stroh-Spijer
_______________________

Touch My Pixel
http://www.touchmypixel.com/
phone: +61 3 8060 5321
_______________________

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: using + type inferencing

Nicolas Cannasse
Le 10/11/2011 08:48, Tarwin Stroh-Spijer a écrit :

> I've got a DateTools2 class like so:
>
> class DateTools2
> {
> public static function setTime(d:Date, h:Int)
> {
> return new Date(d.getFullYear(), d.getMonth(), d.getDate(), h, 0, 0);
> }
> }
>
> Now if I try and do:
>
> var d = Date.now();
> var d2 = d.setTime(1).setTime(2);
>
> It will complain that the second call doesn't exist.

Works using haXe/SVN.

Seems a bit strange however, could you try to check with a very simple
example ? Then if you can't reproduce try to reduce your code to see
what makes it happen.

Best,
Nicolas

--
haXe - an open source web programming language
http://haxe.org