On May 3, 2006, at 1:07 PM, [EMAIL PROTECTED] wrote:

On May 03, 2006, at 18:04 UTC, Jason Essington wrote:

Sub badFruit(ByRef f As Fruit)
    f = new Orange()
End Sub

Dim a as new Apple()
badFruit(a)

Rather than getting a compile exception at badFruit(a), I would
expect to get an IllegalCastException at f = new Orange().

Try it! I would expect the compiler to tell you to take a hike (or at least, that you've passed an incorrect type on the badFruit call).

Right, that's what I said ... the compiler whines when you try to pass an apple as a fruit (very silly since an apple is a fruit)

So you can see, just because an Apple IsA Fruit, does NOT mean that
an array of Apples IsA array of Fruits.

B-B-B-But an array of Apples IsA array of Fruits! A rather specific
array of Fruits, but still an array of Fruits.

No, not in RB. It's the element type that is a more specific fruit, not the array itself. The subclass nature of the elements doesn't percolate up to the container.

That is my complaint.


Well, It isn't naivety that makes me think that it should work, it is
that it does work exactly that way in my primary language (Java).

Really? I didn't know that. I'm a bit surprised; in most ways Java's semantics are just like RB's. This is a bit of type looseness I wouldn't have expected from the Java designers.

Actually no. there is no looseness, java is very strict about types, and will whine loudly if you do something illegal, like try to stuff an orange into an array of apples.

Have a look at Java's Arrays class (a utility class that makes certain array operations more convenient)
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/Arrays.html

There are separate methods for each primitive array type, and one for an object array type. That covers all arrays (well, single dimensional arrays anyway)

and arraycopy actually takes objects (arrays are objects too) and deals with them in a more platform dependent manner. http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ System.html#arraycopy(java.lang.Object,%20int,%20java.lang.Object,% 20int,%20int)

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to