Questions tagged [scala-2.10]

Version 2.10 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.10 version of the Scala language. The contents of this version are not yet decided, as it has not yet been released.

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.

590 questions
38
votes
2 answers

Map the Exception of a failed Future

What's the cleanest way to map the Exception of a failed Future in scala? Say I have: import scala.concurrent._ import scala.concurrent.ExecutionContext.Implicits.global val f = Future { if(math.random < 0.5) 1 else throw new Exception("Oh no")…
theon
  • 14,170
  • 5
  • 51
  • 74
38
votes
2 answers

What's the easiest way to use reify (get an AST of) an expression in Scala?

I'm looking at alternatives to -print or javap as a way of figuring out what the compiler is doing in Scala. With the new reflection/macros library, reify seems a good candidate for that, as shown in retronym's macrocosm's desugar. It even shows how…
Daniel C. Sobral
  • 295,120
  • 86
  • 501
  • 681
37
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
  • 41,826
  • 12
  • 125
  • 142
37
votes
5 answers

Scala 2.10 + Json serialization and deserialization

Scala 2.10 seems to have broken some of the old libraries (at least for the time being) like Jerkson and lift-json. The target usability is as follows: case class Person(name: String, height: String, attributes: Map[String, String], friends:…
user1698607
  • 381
  • 1
  • 3
  • 7
35
votes
2 answers

IntelliJ IDEA Report Highlighting error when using routes in Controller

I have a Scala Play project. I'm using Play 2.2.1. I downloaded Scala, Play 2 supported and SBT plugins. Everything is OK, but When I call route on Action in the Controller appear following error(Look screenshots): I'm using IntelliJ IDEA 12.1.6…
SBotirov
  • 13,872
  • 7
  • 59
  • 81
35
votes
1 answer

Alternative to Scala REPL breakIf in 2.10

I was reading here about using the breakIf method in the REPL code for interactive debugging, but then I found this post saying that break and breakIf were removed from ILoop in Scala 2.10. Unfortunately, that post doesn't explain why the code was…
DaoWen
  • 32,589
  • 6
  • 74
  • 101
34
votes
4 answers

Scala. Can case class with one field be a value class?

Scala 2.10 introduced value classes. They are very usefull for writing typesafe code. Moreover there are some limitations, some of them will be detected by compiler, and some will require allocation in runtime. I want to create value classes using…
Alex Povar
  • 4,890
  • 3
  • 29
  • 44
30
votes
2 answers

Scala 2.10 reflection, how do I extract the field values from a case class, i.e. field list from case class

How can I extract the field values from a case class in scala using the new reflection model in scala 2.10? For example, using the below doesn't pull out the field methods def getMethods[T:TypeTag](t:T) = typeOf[T].members.collect { case…
J Pullar
  • 1,915
  • 2
  • 18
  • 30
28
votes
1 answer

How do the new Scala TypeTags improve the (deprecated) Manifests?

Possible Duplicate: Scala 2.10: What is a TypeTag and how do I use it? I have been reading about the new TypeTags which come along with the new reflection api. It seems that Manifests are supposed to be replaced with that new concept. Can anyone…
neutropolis
  • 1,884
  • 15
  • 34
26
votes
2 answers

Scala Constructor Parameters

What is the difference between a private var constructor parameter and a constructor parameter without val/var? Are they same in terms of scope/visibility? Ex: class Person(private var firstName:String, lastName:String)
user2456976
  • 1,248
  • 2
  • 11
  • 19
26
votes
2 answers

What exactly did Scala improve with pattern matching in 2.10?

I found it interesting that this puzzler, specifically this code: val (i, j): (Int, Int) = ("3", "4") Fails at runtime in Scala 2.9.1, but fails at compile time w/ 2.10 M3(which is great). I try to track what's coming in new Scala releases, but…
Adam Rabung
  • 5,232
  • 2
  • 27
  • 42
25
votes
4 answers

Is there a Round Robin/Circular Queue available in Scala Collections

Is there a Round Robin Queue available in Scala Collections? I need to repeatedly iterate a list that circles through itself val x = new CircularList(1,2,3,4) x.next (returns 1) x.next (returns 2) x.next (returns 3) x.next (returns 4) x.next…
user2780187
  • 677
  • 7
  • 16
25
votes
7 answers

How to remove an item from a list in Scala having only its index?

I have a list as follows: val internalIdList: List[Int] = List() internalIdList = List(11, 12, 13, 14, 15) From this list would remove the third element in order to obtain: internalIdList = List(11, 12, 14, 15) I can not use a ListBuffer, are…
YoBre
  • 2,520
  • 5
  • 27
  • 37
24
votes
1 answer

How to get more information about 'feature' flag warning?

When compiling an application with Play2, sometimes these kind of message appears on my terminal : [info] Compiling 1 Scala source to ~/target/scala-2.10/classes... [warn] there were 1 feature warnings; re-run with -feature for details [warn]…
i.am.michiel
  • 10,281
  • 7
  • 50
  • 86
23
votes
2 answers

How to get ClassTag form TypeTag, or both at same time?

I have some code like this: class ReflectiveJsonFormat[T:TypeTag] extends JsonFormat[T] { def write(x: T) : JsValue = { val t = typeOf[T] val getters = t.declarations.filter { s => s.isMethod && s.asMethod.isGetter } val mirror =…
Rob N
  • 15,024
  • 17
  • 92
  • 165
1
2
3
39 40