I am try to construct immutable Sets/Maps from a Seq. I am currently doing the following:
val input: Seq[(String, Object)] = //.....
Map[String, Object]() ++ input
and for sets
val input: Seq[String] = //.....
Set[String]() ++ input
Which seems a little convoluted, is there a better way?
...
I am playing a bit with scala, using maven and scala plugin.
I can't find a way to have
mvn test
report failure details - in particular, whenever some function returns wrong reply, I am getting information about the failure, but I have no way to see WHICH wrong reply was reported.
For example, with test like:
object MyTestSpec ext...
Hi all,
I am using Buildr with a java/scala project.
Dependencies are descried in the buildfile. An as you may know, Buildr downloads dependencies into ~.m2 folder (as maven2 does).
I am wondering how can I import dependencies (from ~.m2 folder or buildfile) into my Intellij project to enjoy the code completion and error detection amo...
Self-types seem to be important so I want to know why they are useful. From what I can gather, a self-type for a trait A:
trait B
trait A { this: B => }
says that "A cannot be mixed into a concrete class that does not also extend B".
(sidenote: I'm also seeing this fail in the REPL when mixed into an abstract class that does not e...
In Scala, what is the advantage of using an abstract class instead of a trait (apart from performance)? At first glance it seems like abstract classes can be replaced by traits in most cases.
...
Scala beginner's question... (The example is from the book 'Programming in Scala'.)
Given a class 'Rational' and the following method definition:
def add(that: Rational): Rational =
new Rational(
this.numer * that.denom + that.numer * this.denom,
this.denom * that.denom
)
I can successfully overload the add method with a ...
Hi All,
I've got a simple question for you :)
I have the following Scala code, which compiles and gives an error.
Actually I am expecting the code not be compiled as it has an abstract type CT. And the error is even more confusing as the scala says it can't find the type CT.
class Currency { type ct=Currency }
val c = new Currency...
(How) is it possible to represent monads in Scala in a generic way (like the Monad typeclass in Haskell)? Is it somehow possible to define a trait Monad for this purpose?
...
Has anyone had success developing a substantial Android app in Scala? Is it a viable option yet? Are there any mature development environments? Given the state of the Scala Eclipse plug-in, it looks as if there is no good IDE support at all other than possibly IntelliJ Ultimate.
A few people have posted tutorials describing how to fudge...
In theory, Dalvik executes any virtual machine byte code, created for example with the compilers of
AspectJ
ColdFusion
Clojure
Groovy
JavaFX Script
JRuby
Jython
Rhino
Scala
Are there already working versions of bytecode compilers for Dalvik available for other languages than Java?
...
I'm trying to figure out the popularity of scala and how many SO users actually use it in the workplace?
Here are some scala links
...
In Java you can create an instance of Some using the constructor, i.e. 'new Some( value)', but None has no partner class. How do you pass None to a Scala function from Java?
...
What is the motivation for Scala assignment evaluating to Unit rather than the value assigned?
A common pattern in I/O programming is to do things like this:
while ((bytesRead = in.read(buffer)) != -1) { ...
But this is not possible in Scala because...
bytesRead = in.read(buffer)
.. returns Unit, not the new value of bytesRead.
S...
For using a 3rd party library, I need a w3c DOM Document. However, creating the xml nodes is easier in Scala. So I'm looking for a way for converting a scala xml element to w3c dom. Obviously, I can serialize to a string and parse it, but I'm looking for something more performant.
...
What is the conceptual difference between abstract classes and traits?
...
Started to learn LINQ with C#.
Especially LINQ to Objects and LINQ to XML.
I really enjoy the power of LINQ.
I learned that there is something called JLINQ a Jscript implementation.
Also (as Catbert posted) Scala will have LINQ
Do you know if LINQ or something similar will be a part of Java 7?
Update: Interesting post from 2008 - http...
hi :)
I'm having major problems getting Undercover to work using Mavern
I'm using ScalaTest for unit tests and this is working perfectly
When I run Undercover though it simply creates empty files
I think it's probably a problem with the configuration in my pom.xml (but the documentation for Undercover is a little sketchy)
Help :)
Tha...
I'm using a raw strings but when I print the string I'm getting extra tabs at the start of each line.
val rawString = """here is some text
and now im on the next line
and this is the thrid line, and we're done"""
println(rawString)
this outputs
here is some text
and now im on the next line
and this is the thrid line, and we'...
Hello
I was trying to pull environment variables into a scala script using java Iterators and / or Enumerations and realised that Dr Frankenstein might claim parentage, so I hacked the following from the ugly tree instead:
import java.util.Map.Entry
import System._
val propSet = getProperties().entrySet().toArray()
val props = (0 u...
To make debug-time introspection into classes easy, I'd like to make a generic toString method in the base class for the objects in question. As it's not performance critical code, I'd like to use Reflection to print out field name/value pairs ("x=1, y=2" etc).
Is there an easy way to do this? I tried several potential solutions, and ...