Re: [Vala] Proper Syntax for Array of Nullable Strings



Jiří Zárevúcky wrote:
tecywiz121 píše v St 20. 01. 2010 v 16:49 -0500:
I am just wondering if it is possible to have an array of nullable
strings, and if so, what is the proper syntax?

Sam


I believe array of class type can always contain nulls. Or am I
mistaken? 

Only without --enable-experimental-non-null.

However, this one fails with --enable-experimental-non-null:

----------------------------------------------------------------------
void main () {
        string?[] a = new string?[10];
}
----------------------------------------------------------------------
demo.vala:2.26-2.26: error: syntax error, expected ( or [
        string?[] a = new string?[10];
                                ^
Compilation failed: 1 error(s), 0 warning(s)
----------------------------------------------------------------------


And this one as well:

----------------------------------------------------------------------
void main () {
        string?[] a = new string[10];
}
----------------------------------------------------------------------
demo.vala:2.12-2.29: error: Assignment: Cannot convert from `string[]'
to `string?[]'
        string?[] a = new string[10];
                  ^^^^^^^^^^^^^^^^^^
Compilation failed: 1 error(s), 0 warning(s)
----------------------------------------------------------------------

I think the first case should succeed. The latter case seems to fail
rightly.


Best regards,

Frederik



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