[Vala] Unboxing Value Types




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


                                          


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