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



Sam Wilson píše v St 20. 01. 2010 v 17:42 -0500:


Date: Wed, 20 Jan 2010 23:23:11 +0100
From: scumm_fredo gmx net
To: vala-list gnome org
Subject: 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




Does this qualify as a bug?  Because as it stands now, I cannot define an array of nullable strings (or 
floats or anything else for that matter)

another problem I am having a hard time wrapping my head around is whether or not



string?[] a = new string?[10];



would define an nullable array of strings, or an array of nullable strings.  Is it possible to define a 
nullable array of nullable strings? How?

Sam
                                        

Unless you use *experimental* features, you can't define *non-nullable*
array. Since you seem to be new to Vala, I strongly suggest not using
experimental features.


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]