I was speechless when I learned Seq by default in < 2.13 is mutable
-
-
Replying to @VivekRagunathan @NicolasRinaudo
But is this actually true?pic.twitter.com/fy99LyxGNi
1 reply 0 retweets 0 likes -
Replying to @propensive @NicolasRinaudo
I don't know if there is a difference between repl and sbt/scala project. But if you open a scala project in say IntelliJ and browse to definition on a Seq you can see that it points to the mutable version. Not sure but could repl br using a different predef?
1 reply 0 retweets 0 likes -
Replying to @VivekRagunathan @NicolasRinaudo
If `collection.mutable._` were imported, that would do it... but I doubt that's where the idea came from. Note that mutable.Seq[T] <:< Seq[T] which means that you can pass a mutable sequence to a method which requests an immutable one. Could that be the source of confusion?
1 reply 0 retweets 0 likes -
Replying to @propensive @VivekRagunathan
It's related - the Seq type that's in scope by default is defined here: https://www.scala-lang.org/api/2.10.3/#scala.package … That's an alias for scala.collection.Seq, which is the supertype of both mutable and immutable. Meaning that you think your method expects an immutable Seq, but gets a mutable one.
2 replies 0 retweets 1 like -
Not sure why I linked the 2.10 doc, that's still the case in 2.12: https://www.scala-lang.org/api/2.12.12/scala/index.html#Seq[+A]=Seq[A …]
1 reply 0 retweets 0 likes -
Replying to @NicolasRinaudo @VivekRagunathan
Well, I did my test in 2.10...
1 reply 0 retweets 0 likes -
Replying to @propensive @VivekRagunathan
You’re not testing the “right” thing. Write a method that takes a Seq, then pass a mutable.Seq. This compiles but isn’t coherent with what you’d expect, since unqualified Map, say, is immutable.
1 reply 0 retweets 0 likes -
Replying to @NicolasRinaudo @VivekRagunathan
I was trying to explain why you might have linked the 2.10 docs...
1 reply 0 retweets 0 likes -
Replying to @propensive @VivekRagunathan
Ah, yes, another fine example of me making a fool of myself while trying to look clever. This seems to happen a lot.
1 reply 0 retweets 1 like
Obviously, I only consider myself to blame... and if I'm not careful you'll stop replying to me in the interests of self-preservation...
-
-
Replying to @propensive @VivekRagunathan
I've come to terms with the fact that my average "tweets to stupidity" is 2. You'll not be rid of me that easily!
0 replies 0 retweets 2 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.