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
1
vote
3 answers

how to force method to be implemented in concrete subclass from trait

I have a method in my trait def controller: AnyRef but my concrete class was not implementing that method and it was still compiling. The compiler doesn't let me add abstract to that method either. How can I create a method in a trait that forces…
Dean Hiller
  • 19,235
  • 25
  • 129
  • 212
1
vote
1 answer

How to translate exception to another using futures in addition to map and flatMap

We currently have code like this def somemethod() : Future[Resp] = { val responseFuture = service.serveV2(req) val nextFuture = responseFuture flatMap { //do something on success including call to next async service } …
Dean Hiller
  • 19,235
  • 25
  • 129
  • 212
1
vote
1 answer

how to allow passing in a => AnyRef function and call that function

I have the following code class LazyLogRecord( level: javalog.Level, messageGenerator: => AnyRef ) extends LogRecord(level, "") { // for each logged line, generate this string only once, regardless of how many handlers there are: …
Dean Hiller
  • 19,235
  • 25
  • 129
  • 212
1
vote
0 answers

Scala json not playing nicely with base64 encode

I'm simulating sending a JSON request ~500kb. The test isn't testing what's in the request simply testing the load a JSON request of this size would place on server. Code is as follows: val values = """ |"created" : "now", |"metaData" : "%s", …
user2313658
  • 41
  • 1
  • 2
  • 7
1
vote
1 answer

Scala, read file manipulate each line, insert each line into list

I'm reading a file line by line, replacing substring "replace" with substring "replacment". Once string manipulation is complete I want to insert each line into a list. def importFile(replaceString:String, filePath:String, replacement:String)= { …
user2313658
  • 41
  • 1
  • 2
  • 7
1
vote
1 answer

how do I know if these two versions of scala are exactly the same?

I have two different copies of scala version 2.9.2 from the Scala-Lang website. No. 1 is binary code: scala-2.9.2.tgz No. 2 is source code: scala-sources-2.9.2.tgz I built scala from the source code. I have tried using both in an application and…
Hal
  • 69
  • 7
1
vote
1 answer

how to use a different version of scala library with scala ide 3.0.2?

I've got the newest Scala IDE (3.0.2) and I want to compile my stuff with Scala 2.9.3. I've added that version of Scala as a Maven dependency and removed the default 2.10.0 that the IDE bundles with the new project (not my system Scala version, by…
Walrus the Cat
  • 2,314
  • 5
  • 35
  • 64
1
vote
2 answers

Scala Map Transformation

Can someone recommend a functional way to transform the map specified below from Map("host.config.autoStart.powerInfo[1].startOrder" -> -1, "host.config.autoStart.powerInfo[1].startAction" -> "None", "host.config.autoStart.powerInfo[1].key"…
conikeec
  • 209
  • 2
  • 14
1
vote
1 answer

Scala 2.9 : Any way to use toArray on a Set inline

If the answer to my question is already out here please link it... I did look. I'm working through some tutorials and it struck me a little odd that this code: val my_set = Set("one","two","three") println("First Value:" + my_set.toArray(0)) when…
rwheadon
  • 241
  • 1
  • 12
1
vote
1 answer

Scala Futures - confused by CPU load and output of two approaches

I made a mistake while implementing scala futures, or at least i think I did, and just noticed it however, when I fix the mistake it runs much slower than when I don't use futures. Can someone help me to understand what is going on? I have a slow…
Mike Lavender
  • 319
  • 1
  • 4
  • 13
1
vote
3 answers

What is the difference between "Array.fill(2)(new A)" and "val a=new A; Array.fill(2)(a)"?

Minimal Working Example (Scala 2.9.2): object Main extends App { class A { var a=0 } val b = Array.fill(2)(new A) b(1).a = 9 println(b(0).a) //prints 0 println(b(1).a) //prints 9 val a = new A val c = Array.fill(2)(a) c(1).a =…
user445107
1
vote
1 answer

Scala implicit conversion blocked somehow

I wrote a small service with Scalatra that does two things: serve JSON data serve same data as an Excel sheet JSON is done with spray-json, Excel - with apache POI Basically, I wrote two methods in my ScalatraServlet implementation: def…
F0RR
  • 1,590
  • 4
  • 16
  • 30
1
vote
1 answer

Actor not response

Take a look at the code snippet: import scala.actors.Actor._ object ActorTest1 extends Application { val caller = self val badActor = actor { receive { case msg => println(Thread.currentThread()+ " "+msg) …
爱国者
  • 4,298
  • 9
  • 47
  • 66
1
vote
0 answers

Implementation of abstract traits in with clause

Possible Duplicate: In Scala how can I advise my own methods? Assume: trait SomeAbstractTrait { val transform : Int => Int } Why does the following work: new SomeClass() with SomeTrait with SomeAbstractTrait { val transform : Int =>…
Voo
  • 29,040
  • 11
  • 82
  • 156
0
votes
4 answers

Inner class with upper bound

I'd like to create a generic class with type parameter T which then creates instances of an inner class wrapping values of type T. I thought that if I used upper bound to tell that T must be subtype of eg. String, I'll be able to create instances of…
Zoltán Balázs
  • 157
  • 1
  • 8