Questions tagged [scala-2.8]

Version 2.8 of the Scala language for the JVM. Use only if your question is specifically related to features of this version.

This tag is for the 2.8 version of the Scala language.

Version 2.8 was notable for many back-breaking changes to the core language and APIs. It had grown to such a size as to warrant being called Scala 3 but since there were many books and articles referencing 2.8 already in production, the community and language creator Martin Odersky kept the 2.8 version to reduce confusion.

Use only if your question is specifically related to features of this version. Just because you are using this version, doesn't mean you need this tag. Use in addition to or instead of this tag.

See for more information.

358 questions
873
votes
18 answers

Is the Scala 2.8 collections library a case of "the longest suicide note in history"?

I have just started to look at the Scala collections library re-implementation which is coming in the imminent 2.8 release. Those familiar with the library from 2.7 will notice that the library, from a usage perspective, has changed little. For…
oxbow_lakes
  • 133,303
  • 56
  • 317
  • 449
232
votes
4 answers

Scala 2.8 breakOut

In Scala 2.8, there is an object in scala.collection.package.scala: def breakOut[From, T, To](implicit b : CanBuildFrom[Nothing, T, To]) = new CanBuildFrom[From, T, To] { def apply(from: From) = b.apply() ; def apply() = b.apply() } I…
oxbow_lakes
  • 133,303
  • 56
  • 317
  • 449
212
votes
4 answers

What do <:<, <%<, and =:= mean in Scala 2.8, and where are they documented?

I can see in the API docs for Predef that they're subclasses of a generic function type (From) => To, but that's all it says. Um, what? Maybe there's documentation somewhere, but search engines don't handle "names" like "<:<" very well, so I…
Jeff
  • 14,831
  • 15
  • 49
  • 59
161
votes
19 answers

How to write to a file in Scala?

For reading, there is the useful abstraction Source. How can I write lines to a text file?
yura
  • 14,489
  • 21
  • 77
  • 126
118
votes
4 answers

What is a "context bound" in Scala?

One of the new features of Scala 2.8 are context bounds. What is a context bound and where is it useful? Of course I searched first (and found for example this) but I couldn't find any really clear and detailed information.
Jesper
  • 202,709
  • 46
  • 318
  • 350
112
votes
2 answers

Overload constructor for Scala's Case Classes?

In Scala 2.8 is there a way to overload constructors of a case class? If yes, please put a snippet to explain, if not, please explain why?
Felix
  • 8,385
  • 10
  • 40
  • 59
108
votes
6 answers

How can I convert immutable.Map to mutable.Map in Scala?

How can I convert immutable.Map to mutable.Map in Scala so I can update the values in Map?
Łukasz Lew
  • 48,526
  • 41
  • 139
  • 208
96
votes
4 answers

Package objects

What are package objects, not so much the concept but their usage? I've tried to get an example working and the only form I got to work was as follows: package object investigations { val PackageObjectVal = "A package object val" } package…
Don Mackenzie
  • 7,953
  • 7
  • 31
  • 32
86
votes
7 answers

What are Scala continuations and why use them?

I just finished Programming in Scala, and I've been looking into the changes between Scala 2.7 and 2.8. The one that seems to be the most important is the continuations plugin, but I don't understand what it's useful for or how it works. I've seen…
Dave
  • 7,589
  • 12
  • 36
  • 42
73
votes
1 answer

Scala 2.8 collections design tutorial

Following on from my breathless confusion, what are some good resources which explain how the new Scala 2.8 collections library has been structured. I'm interested to find some information on how the following fit together: The collection…
oxbow_lakes
  • 133,303
  • 56
  • 317
  • 449
65
votes
1 answer

Does the @inline annotation in Scala really help performance?

Or does it just clutter up the code for something the JIT would take care of automatically anyway?
Alex R
  • 11,364
  • 15
  • 100
  • 180
56
votes
6 answers

How to choose a random element from an array in Scala?

For example, there is a Scala array val A = Array("please", "help", "me"). How to choose a random element from this array?
sam
  • 2,093
  • 3
  • 17
  • 10
52
votes
1 answer

How do I exclude/rename some classes from import in Scala?

Language FAQ says import scala.collection.mutable.{_, Map => _, Set => _} should import all classes from package scala.collection.mutable, except Map and Set. But it gives me this error: error: '}' expected but ',' found. import…
Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487
51
votes
4 answers

What's the right way to use scala.io.Source?

In many examples, it is described that you can use scala.io.Source to read a whole file like this: val str = scala.io.Source.fromFile("test.txt").mkString() But closing the underlying stream is not mentioned. Why does Scala not provide a convenient…
woods
  • 817
  • 1
  • 7
  • 9
51
votes
1 answer

Function syntax puzzler in scalaz

Following watching Nick Partidge's presentation on deriving scalaz, I got to looking at this example, which is just awesome: import scalaz._ import Scalaz._ def even(x: Int) : Validation[NonEmptyList[String], Int] = if (x % 2 ==0) x.success…
oxbow_lakes
  • 133,303
  • 56
  • 317
  • 449
1
2 3
23 24