Yes, you would need to know the specific implementation of `Seq#apply`... which is somewhat arbitrarily a `List`.
-
-
Replying to @propensive @NicolasRinaudo
Honest question: why do people still use `Seq`? I thought it was on its way out, and it was a pretty big wart in 2018 that I always banned in my codebases for lack of clarity and how it obfuscates the complexity class of the program...
3 replies 0 retweets 5 likes -
Replying to @bkmlep @propensive
My guess is, because Java people have been taught to program to the interface, not the implementation. Did you realise the nastiest thing about Seq (as it was in 2.11, at least)? How everybody believes it's immutable but you get the mutable version by default?
3 replies 0 retweets 7 likes -
Replying to @NicolasRinaudo @propensive
I was speechless when I learned Seq by default in < 2.13 is mutable
1 reply 0 retweets 0 likes -
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 -
Replying to @NicolasRinaudo @VivekRagunathan
In Liskov terms, the facts of the existence of certain methods are inherited properties, but the fact of the object's immutability is not. This is because there's no direct way to encode the fact of immutability in the type system...
1 reply 0 retweets 0 likes -
Replying to @propensive @VivekRagunathan
I'm not sure we're talking about the same thing. What you're saying is certainly true, but seems only faintly related to what I'm (poorly) trying to explain. Here, code should remove any potential ambiguity:https://scastie.scala-lang.org/no9l4VL4TrOoN8kQ3eosPg …
1 reply 1 retweet 2 likes
No, I understood correctly... which means I showed that poorly! Oh dear!
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.