- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
[B >: A] any different than [A <: B]?
Sat, 2010-02-27, 02:59
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
Sat, 2010-02-27, 08:07
#2
Re: [B >: A] any different than [A <: B]?
On Fri, Feb 26, 2010 at 8:59 PM, Brian Maso <brian@blumenfeld-maso.com> wrote:
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
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
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.