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
22
votes
3 answers

Is there a tutorial on Scala 2.10's reflection API yet?

Is there a good place to get a thorough tutorial of Scala 2.10's reflection API? I see lots of blog posts written over the course of the last two years, but many of the details of these posts are already out of date. Now that 2.10 is publicly…
Bill
  • 44,502
  • 24
  • 122
  • 213
22
votes
2 answers

Finding type parameters via reflection in Scala 2.10?

Using type tags, I'm able to see the parameters of some type: scala> import scala.reflect.runtime.universe._ import scala.reflect.runtime.universe._ scala> typeOf[List[Int]] res0: reflect.runtime.universe.Type = List[Int] But I just can't quite…
Tim
  • 1,615
  • 14
  • 17
21
votes
5 answers

Is it possible to use IN clause in plain sql Slick?

For example, I want to create the following query: SELECT c.* FROM Coffees c WHERE c.name IN ('robusta', 'arabica') My attempt failed: val cnames = List("robusta", "arabica") sql""" SELECT c.* FROM Coffees c WHERE c.name IN ${cnames} """ could…
Rogach
  • 26,050
  • 21
  • 93
  • 172
21
votes
1 answer

why is scala actors deprecated in 2.10?

I was just comparing different scala actor implementations and now I'm wondering what could have been the motivation to deprecate the existing scala actor implementation in 2.10 and replace the default actor with the Akka implementation? Neither the…
bluenote10
  • 23,414
  • 14
  • 122
  • 178
21
votes
4 answers

How to know if an object is an instance of a TypeTag's type?

I have a function which is able to know if an object is an instance of a Manifest's type. I would like to migrate it to a TypeTag version. The old function is the following one: def myIsInstanceOf[T: Manifest](that: Any) = …
neutropolis
  • 1,884
  • 15
  • 34
20
votes
2 answers

Any way to obtain a Java class from a Scala (2.10) type tag or symbol?

Looks like this gets me close, but (a) not quite (see below), and (b) using the string representation of a name feels like a hack... scala> import scala.reflect.runtime.universe._import scala.reflect.runtime.universe._ scala> val t = typeOf[Int] t:…
Tim
  • 1,615
  • 14
  • 17
19
votes
2 answers

How do I access default parameter values via Scala reflection?

Let's say a I have a class: case class Foo(id: Int, name: String, note: Option[String] = None) Both the constructor and the apply method in the automatically generated companion object take three parameters. When viewed via reflection, the third…
Erik Engbrecht
  • 3,174
  • 17
  • 23
19
votes
2 answers

How do I print an expanded macro in Scala?

I am writing a macro in Scala, but when I call it I get an error message saying "Double does not take parameters". Clearly there is something wrong with how the macro builds the AST. So how can I see the expanded macro? Is there a way to call the…
Kim Stebel
  • 41,826
  • 12
  • 125
  • 142
18
votes
3 answers

Can I define and use functions outside classes and objects in Scala?

I begin to learn Scala and I'm interesting can I define and use function without any class or object in Scala as in Haskell where there is no OOP concept. I'm interested can I use Scala totally without any OOP concept? P.S. I use IntelliJ plugin for…
MainstreamDeveloper00
  • 8,436
  • 15
  • 56
  • 102
17
votes
2 answers

String interpolation: f or s

I wonder, is there any difference between these two: val a = 123 println(f"hello1 $a") // 1 println(s"hello1 $a") // 2
Incerteza
  • 32,326
  • 47
  • 154
  • 261
17
votes
2 answers

How are lazy val class variables implemented in Scala 2.10?

This answer to What's the (hidden) cost of Scala's lazy val? shows how they were implemented in Scala 2.7. But as the comments say, this must have changed since then, so I'm curious, what's the current (2.10) implementation of class lazy val…
Petr
  • 62,528
  • 13
  • 153
  • 317
17
votes
2 answers

How can a parameter's default value reference another parameter?

How can a parameter's default value reference another parameter? If it cannot, how to work around that? case class A(val x:Int, val y:Int = x*2) Error (reasonably enough): scala> case class B(val x:Int, val y:Int = x*2) :7: error: not…
Dominykas Mostauskis
  • 7,797
  • 3
  • 48
  • 67
17
votes
3 answers

What does "reflective access of structural type member method should be enabled..." warning mean in Scala?

After switching to Scala 2.10 I get tons of warnings: reflective access of structural type member method ... should be enabled by making the implicit value language.reflectiveCalls visible What does it mean?
Ivan
  • 63,011
  • 101
  • 250
  • 382
16
votes
1 answer

How to convert an anonymous function to a method value?

With this code val foo = List('a', 'b', 'c') aString.forall(foo.contains(_)) IntelliJ highlights foo.contains(_) and suggests "Anonymous function convertible to method value". I have researched eta expansion, but am unable to see how I could…
Lasf
  • 2,536
  • 1
  • 16
  • 35
16
votes
1 answer

Is using Try[Unit] the proper way?

I recently came across the concept of Try/Success/Failure, and I am wondering how to use it for a method that has the return type Unit. Is using Try[Unit] the correct way? Maybe I am too influenced from my Java background, but is it a good idea to…
Karda
  • 303
  • 2
  • 8
1 2
3
39 40