Re: [Vala] Unboxing Value Types



Sam Wilson píše v Út 19. 01. 2010 v 11:02 -0500:
Hello again!

random question, how are you supposed to unbox a value type (say float) ?

Here is how I am trying to do it, but it won't compile:

[code]

public void main(string[] args)
{
    float? a = 6;
    printfloat((float)a);
}

public void printfloat(float t)
{
    stdout.printf("%f\n", t);
}

[/code]

The output from valac and cc

unbox.vala: In function ‘_main’:
unbox.vala:4: error: pointer value used where a floating point value was expected
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)

----

compiled with Vala 0.7.9:  `valac -g --enable-experimental --enable-checking -o junk *.vala`

Thanks,
Sam


 

This is a bug that was fixed a few days ago. It should work with master.
In the meantime, avoid using explicit casts. Implicit cast should work
for assignment.

Attachment: signature.asc
Description: Toto je digitálně podepsaná část zprávy



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]