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
12
votes
2 answers

Is it possible to convert a TypeTag to a Manifest?

Our library uses TypeTags, but now we need to interact with another library which requires Manifests. Is there any simple way to create a Manifest from a TypeTag?
Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487
12
votes
1 answer

How can I get Class[T] from an implicit ClassTag[T]?

I'd like to have a method like def retrieve[T](value: Option[T])(implicit ct: ClassTag[T]): T; Inside this method I need to call a Java method (beyond my control) to create an instance of T that requires Class[T]: public T construct(clazz:…
Petr
  • 62,528
  • 13
  • 153
  • 317
12
votes
1 answer

How do I format a string with string interpolation in Scala as a fixed width string?

I'm interfacing with a really old system and the file I need to generate needs a field that is a formed from a string but needs to be exactly 15 in width. I want something like this: val companyName = "FooBar, Inc" // 11 chars f"$companyName%s" To…
myyk
  • 1,537
  • 1
  • 15
  • 35
12
votes
1 answer

How can I get Scala ToolBox to see REPL definitions?

Back when reflection was still incipient, on the days of Scala 2.10.0 milestones, I asked a question about how could I use it to see the trees of code snippets from REPL. The excellent answer went further than I asked, and showed how they can be…
Daniel C. Sobral
  • 295,120
  • 86
  • 501
  • 681
12
votes
1 answer

Scala 2.10 and package reflection

How can I reflect over package hierarchies in Scala 2.10's reflection? Can I find out what subpackages exist, or what the parent packages are?
Daniel C. Sobral
  • 295,120
  • 86
  • 501
  • 681
11
votes
2 answers

How to write a Play JSON writes converter for a case class with a single nullable member

In Play 2.3, I have a case class with a single optional double member: case class SomeClass(foo: Option[Double]) I need a JSON write converter that handles the member as nullable: implicit val someClassWrite: Writes[SomeClass] = ??? The Play docs…
Lasf
  • 2,536
  • 1
  • 16
  • 35
11
votes
3 answers

Custom Scala enum, most elegant version searched

For a project of mine I have implemented a Enum based upon trait Enum[A] { trait Value { self: A => _values :+= this } private var _values = List.empty[A] def values = _values } sealed trait Currency extends Currency.Value object…
vchuravy
  • 1,208
  • 10
  • 22
11
votes
1 answer

Why sbt compile doesn't copy unmanaged resources to classpath?

Could you tell me why sbt compile doesn't copy unmanaged resources to classpath? On the other hand sbt package does. As result I can't start debugging unless I invoke package call manually :( I'm using SBT 0.12.1 Below is my build.sbt. import…
expert
  • 29,290
  • 30
  • 110
  • 214
11
votes
1 answer

In Scala 2.10, how do you create a ClassTag given a TypeTag

I'd like to define a function that returns an Array, and I have a TypeTag. Can I generate the required ClassTag? scala> import scala.reflect.runtime.universe._ import scala.reflect.runtime.universe._ scala> def fun[X: TypeTag]: Array[X] =…
Adam Klein
  • 476
  • 1
  • 4
  • 13
11
votes
1 answer

How can I reuse definition (AST) subtrees in a macro?

I am working in a Scala embedded DSL and macros are becoming a main tool for achieving my purposes. I am getting an error while trying to reuse a subtree from the incoming macro expression into the resulting one. The situation is quite complex, but…
neutropolis
  • 1,884
  • 15
  • 34
10
votes
2 answers

How to print @ symbol in HTML with play framework (scala)

I am new to Scala and play 2.1 and I come from a PHP background. I am not able to print the @ symbol in HTML. I am getting the following error: not found: value Hotmail Here is my code: myname Please let me know how I…
user2822316
10
votes
3 answers

Scala Play 2.2 application crashes after deploying in Heroku: target/start No such file or directory

I've been fighting with this for hours and I can't figure out why after deploying my Scala Play 2.2 application in Heroku I get this stacktrace: 2013-09-30T01:05:09.413177+00:00 heroku[web.1]: Starting process with command `target/start…
Carla
  • 205
  • 3
  • 10
10
votes
3 answers

spray-json and list marshalling

I'm using spray-json to marshal lists of custom objects into JSON. I have the following case class and its JsonProtocol. case class ElementResponse(name: String, symbol: String, code: String, pkwiu: String, remarks: String, priceNetto: BigDecimal,…
Marcin Cylke
  • 2,100
  • 2
  • 21
  • 40
10
votes
1 answer

Requesting more information about @inline from the compiler?

The documentation for @inline states: An annotation on methods that requests that the compiler should try especially hard to inline the annotated method. However, unlike the similar @tailrec annotation, the compiler does not (by default) offer any…
Alex DiCarlo
  • 4,851
  • 18
  • 34
10
votes
1 answer

Set the parallelism level for all collections in Scala 2.10?

I understand how to set the parallelism level for a single parallel collection, via the mutable tasksupport field (c.f. https://stackoverflow.com/a/5425354/82970). How can I set the parallelism level for all new parallel collections in Scala…
Scott Morrison
  • 3,100
  • 24
  • 39