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

deprecation of List.--

2 replies
Iulian Dragos 2
Joined: 2009-02-10,
User offline. Last seen 42 years 45 weeks ago.
For sure there is a reason.. someone can point it out? "filterNot(ys contains)" is a pretty verbose replacement. The definition of '--' in Subtractable seems to allow for a -- in List.
iulian

--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais
Kevin Wright
Joined: 2009-06-09,
User offline. Last seen 49 weeks 3 days ago.
Re: deprecation of List.--
Wasn't it to do with inconsistent behaviour in mutable vs immutable lists?

On 17 May 2010 17:02, Iulian Dragos <iulian.dragos@epfl.ch> wrote:
For sure there is a reason.. someone can point it out? "filterNot(ys contains)" is a pretty verbose replacement. The definition of '--' in Subtractable seems to allow for a -- in List.
iulian

--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais



--
Kevin Wright

mail/google talk: kev.lee.wright@googlemail.com
wave: kev.lee.wright@googlewave.com
skype: kev.lee.wright
twitter: @thecoda

odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: deprecation of List.--


On Mon, May 17, 2010 at 6:02 PM, Iulian Dragos <iulian.dragos@epfl.ch> wrote:
For sure there is a reason.. someone can point it out? "filterNot(ys contains)" is a pretty verbose replacement. The definition of '--' in Subtractable seems to allow for a -- in List.
The problem is that +, ++, -, -- come in a package: any class that supports one also supports the others. And List.+ is
impossible because of the bad interaction with String +.

You might be tempted to use `diff` but it does something different if the list has duplicates.

scala> List(1, 1, 1, 1) -- List(1)
warning: there were deprecation warnings; re-run with -deprecation for details
res0: List[Int] = List()

scala> List(1, 1, 1, 1) diff List(1)
res1: List[Int] = List(1, 1, 1)

Cheers

 -- Martin


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