[haXe] conditionnal if else
Franco Ponticelli
franco.ponticelli at gmail.com
Tue Apr 10 18:37:49 CEST 2007
When you use if to return values all the blocks must return the same type.
This doesn't apply in conditions that are without assignment.
In your first sample try to cast both to Button.
On 4/10/07, filt3r at free.fr <filt3r at free.fr> wrote:
>
> Re :)
> I've another mistake for today :D, when I write :
>
> var b : Button = if ( _bMultiSelect ) new CheckButton () else new
> RadioButton
> ();
>
> compiler gives me : "RadioButton should be CheckButton"
> And when I write :
>
> var b : FButton;
> if ( _bMultiSelect )
> b = new CheckButton ()
> else
> b = new FRadioButton ();
>
> All works correctly.
> If in the 1st case I wouldn't write "var b : Button = ..." but "var b =
> ...", I
> wouldn't be surprised because of inference, but here I don't understand.
> Is it an mistake or I'm wrong ? (I know it's not really important but I
> would
> know)
> N:B: CheckButton and RadioButton extends both "Button"
> Thanks,
> Michel
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.motion-twin.com/pipermail/haxe/attachments/20070410/283746d7/attachment.htm
More information about the Haxe
mailing list