Questions tagged [scala-2.9]

Version 2.9 of the Scala language for the JVM.

Version 2.9 included many changes, notably the introduction of parallel collections.

Scala is a general purpose programming language principally targeting the Java Virtual Machine. Designed to express common programming patterns in a concise, elegant, and type-safe way, it fuses both imperative and functional programming styles. Its key features are: statically typed; advanced type-system with type inference; function types; pattern-matching; implicit parameters and conversions; operator overloading; full interop with Java.

See for more information.

102 questions
157
votes
16 answers

Scala: write string to file in one statement

For reading files in Scala, there is Source.fromFile("file.txt").mkString Is there an equivalent and concise way to write a string to file? Most languages support something like that. My favorite is Groovy: def f = new File("file.txt") // Read def…
smartnut007
  • 5,913
  • 5
  • 40
  • 50
52
votes
1 answer

What is the === (triple-equals) operator in Scala Koans?

I started working my way through the Scala Koans, which is organized around a suite of unit tests with blanks that one needs to fill in. (This idea was modeled after a similar Ruby Koans project.) You start the sbt tool running a test, and it…
pohl
  • 3,078
  • 1
  • 26
  • 48
34
votes
4 answers

Is there a way to declare an implicit val inside a for comprehension?

I have some code with nested calls to flatMap like so: foo.flatMap(implicit f => bar(123).flatMap(b => /* and so on... implicit f is still in scope here.*/ )) Normally, one would write that as a for comprehension, which makes the code a lot more…
Kim Stebel
  • 40,545
  • 12
  • 119
  • 139
24
votes
4 answers

SBT including the version number in a program

I want a program I'm building to be able to report its own version at runtime (e.g. scala myprog.jar --version). Traditionally in a maven project, I'd use resource filtering (pom.xml -> file.properties -> read value at runtime). I know there's…
Chris Eberle
  • 44,989
  • 12
  • 77
  • 112
20
votes
7 answers

How can I fix the missing implicit value for parameter ta: TildeArrow in a test spec

I'm working on a simple test spec using spray and I can't get it to compile correctly, don't know if I'm doing anything wrong. My version of scala is 2.9.3 and spray 1.0.1 (Updating either of them is not a suitable option). Here's my test spec's…
marcelaconejo
  • 219
  • 2
  • 6
19
votes
2 answers

How do I replace the fork join pool for a Scala 2.9 parallel collection?

I've been looking at the new Scala 2.9 parallel collections and am hoping to abandon a whole lot of my crufty amateur versions of similar things. In particular, I'd like to replace the fork join pool which underlies the default implementation with…
18
votes
2 answers

Add tools.jar in the classpath of sbt project

The ':javap' command in the scala 2.9.1 console need the tools.jar (from JDK6) in the 'classpath'. From cmd-line it could be done with '-cp' argument or CLASSPATH environment variable. How to do the same for scala console that invoked from SBT with…
andy legkiy
  • 203
  • 3
  • 7
18
votes
4 answers

What new features will be added to Scala 2.9?

I know parallel collections will become available. What form will these take, and what else are we likely to see?
Kevin Wright
  • 48,726
  • 9
  • 100
  • 155
17
votes
8 answers

coin change algorithm in scala using recursion

I am trying to program the coin change problem in Scala using recursion. The code that i have written is as follows. def countChange(money: Int, coins: List[Int]): Int = { def ways(change: List[Int], size: Int, capacity: Int): Int = { …
Muavia
  • 368
  • 1
  • 3
  • 13
15
votes
3 answers

Why do case classes extend only Product and not Product1, Product2, ..., ProductN?

after I learned that case classes extend Product, I wondered why they do not extend ProductN. E.g., given a code like: case class Foo(a: Int) I'd expect Foo(1).asInstanceOf[Product1[Int]] to work, but it does not (checked with Scala 2.9.1, and…
Blaisorblade
  • 6,172
  • 40
  • 69
14
votes
3 answers

Scala Parallel Collections- How to return early?

I have a list of possible input Values val inputValues = List(1,2,3,4,5) I have a really long to compute function that gives me a result def reallyLongFunction( input: Int ) : Option[String] = { ..... } Using scala parallel collections, I can…
bwawok
  • 12,816
  • 7
  • 30
  • 43
14
votes
1 answer

How can I best troubleshoot "Potentially incompatible versions of dependencies" in sbt

My project gives the following warning: [warn] Potentially incompatible versions of dependencies of {file:/some/path/}default-5bae4a: [warn] org.scala-lang: 2.9.2, 2.9.1 I've got the following dependencies: libraryDependencies ++= Seq( …
iwein
  • 24,288
  • 9
  • 67
  • 108
11
votes
2 answers

Parallel collections in Scala 2.9 and Actors

Ok, this might be a rather silly question, but what is the benefit of using parallel collections within an actor framework? That is, if I'm only dealing with one message at a time from an actor's mailbox, is there even a need for a parallel…
Bruce Ferguson
  • 1,731
  • 2
  • 15
  • 20
10
votes
2 answers

How do you make a list with 100 1s in Scala 2.9

In earlier versions of Scala you can use List.make(100, 1), but that is now deprecated. What is the new proper way to do it?
placeybordeaux
  • 1,928
  • 1
  • 16
  • 35
10
votes
1 answer

What is Scala REPL's tab completion telling me here?

While working my way through Cay S. Horstmann's "Scala for the Impatient", I noticed something interesting revealed by the first exercise in the first chapter. In the Scala REPL, type 3. followed by the Tab key. What methods can be applied? When…
pohl
  • 3,078
  • 1
  • 26
  • 48
1
2 3 4 5 6 7