Yes, tuples are ordered. ("foo","bar") is not the same as ("bar", "foo").
One way to think of tuples is as records or structures where the name given
to each field is it's position in the tuple. So the first tuple is (1 =>
"foo", 2 => "bar") while the second is (1 => "bar", 2 => "foo")
To answer your other question look at this:
class Foo...
class Bar extends Foo
Bar x = new Bar
Foo y = x
x.equals(y) ?
y.equals(x) ?
Of course you expect them to be equal since they have the same identity.
But even if I take identity out of the equation we would still expect
equality
Bar x = new Bar(1)
Foo y = new Bar(1)
Given a typical definition of equality for Bar we would expect these two to
be equal. So static types don't generally affect equality. Thus a Pair<A,B>
might be equal to a Pair<C,D>. In particular, (null, null) should probably
always be equal to (null,null) regardless how the compiler statically typed
them.
On Wed, Feb 25, 2009 at 11:19 AM, Hamlet D'Arcy <[email protected]> wrote:
>
>
> Two questions we asked are
> 1. Are tuples ordered? Tuples seem ordered to me. ("foo", "bar") is
> not equal to ("bar", "foo").
> 2. Are nulls equal? (null, null) seems equal to (null, null) given
> that the type of the tuples are the same... but how can you easily
> discover the generic type at runtime?
>
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---