This page is no longer maintained — Please continue to the home page at www.scala-lang.org

[B >: A] any different than [A <: B]?

2 replies
bmaso
Joined: 2009-10-04,
User offline. Last seen 2 years 40 weeks ago.

From another thread:

def ++[B >: A](that: => Iterator[B]) = ...

Is this any different than

def ++[A <: B](that: => Iterator[B]) = ... ?

In my head they are the same, but maybe I'm missing something?

Best regards,
Brian Maso
(949) 395-8551
brian@blumenfeld-maso.com
twitter: @bmaso
skype: brian.maso
LinkedIn: http://www.linkedin.com/in/brianmaso

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: [B >: A] any different than [A <: B]?

On Fri, Feb 26, 2010 at 05:59:27PM -0800, Brian Maso wrote:
> def ++[B >: A](that: => Iterator[B]) = ...
>
> Is this any different than
>
> def ++[A <: B](that: => Iterator[B]) = ... ?
>
> In my head they are the same, but maybe I'm missing something?

There's the small matter that only half of them would compile, a fact
which must point to how they differ.

ichoran
Joined: 2009-08-14,
User offline. Last seen 2 years 3 weeks ago.
Re: [B >: A] any different than [A <: B]?
On Fri, Feb 26, 2010 at 8:59 PM, Brian Maso <brian@blumenfeld-maso.com> wrote:
From another thread:

def ++[B >: A](that: => Iterator[B]) = ...

Is this any different than

def ++[A <: B](that: => Iterator[B]) = ... ?

In my head they are the same, but maybe I'm missing something?

They express the same relationship between A and B, but that's not all that the [] notation does.  It also declares that the first thing that appears is a new generic.  So [A <: B] means that A is a new generic limited with respect to the existing B, while [B >: A] has the same relationship except that B is new and A is pre-existing.

  --Rex

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland