Or I misunderstood it, or we are coming now on really problems which will
never exist in a real world.
...
Therefore all was it alone for me, what can be the use of this?
I want an array that will be 0 in size when there are 0 'answers'. If
there are more 'answers', then it will be an array of the answers.
The array will be used in a loop. If I used Nothing, instead, the
loop would fail, and I'd need more code to check for that. So, I'd
rather use an empty array.
Cor, I don't follow. Are you saying you don't know of any real reason
there would ever be an empty array? Perhaps there's a better way of
handling the above, with more exotic language contructs, but for now,
being a beginner, I can't see any better (simple!) way of doing this
other than using an empty array.
\\\
Dim a(-1) As Integer
///
(I take Herfrieds sample because this shows it in my idea the nicest.)
Actually, VB .NET's attempt to ease code porting from VB6 by declaring
arrays using the highest index, rather than the array size like every
other language, is, personally, the worst thing I've even seen in the
language. The reasoning behind is interesting but very unconvincing:
http://www.thecodingmonkey.net/2006/03/24/YouHaveToUnderstandTheHistory.aspx
Having said that, I'd rather using " = {}" than "a(-1)", since an
empty set is { }. -1 holds little meaning, it can only be understood
by logical extension of what the maximum index means.
But, by using "a(-1)", it does remind me of this language quirk. I
think perhaps explicitly showing the array bounds from min to max may
be best practive, to indicate precisely what is going on:
Dim tenElements(0 To 9) As Integer
But, it doesn't quite look as good for 0 length ararys:
Dim zeroElements(0 To -1) As Integer
So, I'm not sure. I think, personally, I like { } best.
Zytan