strange return requirement

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

strange return requirement

Baluta Cristian
static public function addWindow (id:String, window:RCAlertView) :Void {
if (windows.exists ( id )) return null;
windows.set ( id, window );
}

Why does this function requires me a return? Not sure will compile fine outside the context.


--
Băluță Cristian
http://ralcr.com
http://imagin.ro

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

Re: strange return requirement

Heinz Hölzer-2
you should change your function to

static public function addWindow (id:String, window:RCAlertView) :Void {
if (windows.exists ( id )) return;
windows.set ( id, window );
}

and it should compile fine. (return null is not the same as void)


Am 10.03.2011 11:57, schrieb Baluta Cristian:
static public function addWindow (id:String, window:RCAlertView) :Void {
if (windows.exists ( id )) return null;
windows.set ( id, window );
}

Why does this function requires me a return? Not sure will compile fine outside the context.


--
Băluță Cristian
http://ralcr.com
http://imagin.ro


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

Re: strange return requirement

Baluta Cristian
Works, thanks. Seems you can return null only if you have to return something other than void.


2011/3/10 Heinz Hölzer <[hidden email]>
you should change your function to

static public function addWindow (id:String, window:RCAlertView) :Void {
if (windows.exists ( id )) return;
windows.set ( id, window );
}

and it should compile fine. (return null is not the same as void)


Am 10.03.2011 11:57, schrieb Baluta Cristian:
static public function addWindow (id:String, window:RCAlertView) :Void {
if (windows.exists ( id )) return null;
windows.set ( id, window );
}

Why does this function requires me a return? Not sure will compile fine outside the context.


--
Băluță Cristian
http://ralcr.com
http://imagin.ro


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



--
Băluță Cristian
http://ralcr.com
http://imagin.ro

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

Re: strange return requirement

Heinz Hölzer-2
> Works, thanks. Seems you can return null only if you have to return
> something other than void.
that's it ;)

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