Right now I have classes like:
abstract class Record {
// Required fields
val productCode:Option[String]
val price:Option[Double]
// Optional fields
val notes:Option[String] = None
val used:Option[Boolean] = Option(false)
}
Then create them:
val r = new Record {
override val productCode = Option("abc")
override val p...
When I execute a Scala script from the command line, a directory named "tmp" is created in my home directory. It is always empty, so I simply deleted it without any apparent problem. Of course, when I run another Scala script, it reappears.
Is there a configuration file/flag by which I can change this behavior?
Thanks.
...
I am making some small "business intelligence" applications/tools that need to talk to other systems. Primarily accounting systems that believe that databases are an integration layer (or are too lazy to provide an api).
What's the easiest way of getting specific data out of a third party database and into my Java objects?
Notes:
(I...
In Scala 2.8, there is an object in scala.collection.package.scala:
def breakOut[From, T, To](implicit b : CanBuildFrom[Nothing, T, To]) =
new CanBuildFrom[From, T, To] {
def apply(from: From) = b.apply() ; def apply() = b.apply()
}
I have been told that this results in:
> import scala.collection.breakOut
> val map : Map[Int,...
I wonder if someone can produce a comparison between Scala and Google 'Go' language (feature by feature, like concurrency models, collections, etc.)?
...
I want to be able to create a Tuple2 from spring config where I explicitly declare the types of my parameters:
<bean class="scala.Tuple2">
<constructor-arg index="0" value="Europe/London" type="java.util.TimeZone" />
<constructor-arg index="1" value="America/New_York" type="java.util.TimeZone" />
</bean>
This does not work...
Where exactly are the *=/+=/etc methods declared for the subclasses of AnyVal? I assume something special is done for these types because as a val those are invalid but as a var they are fine. Is this just yet more syntatic sugar ? I assume it is turning
a *= 5
into
a = a * 5
which obviously fails for a val. Is this intuition corr...
Following on from another question I asked, I wanted to understand a bit more about the Scala method TraversableLike[A].map whose signature is as follows:
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That
Notice a few things about this method:
it takes a function turning each A in the traversable into a B
i...
Following on from my breathless confusion, what are some good resources which explain how the new Scala 2.8 collections library has been structured. I'm interested to find some information on how the following fit together:
The collection classes/traits themselves (e.g. List, Iterable)
Why the Like classes exist (e.g. TraversableLike)
...
New to scala and can't seem to find a reference on this situation.
I'm trying to override some methods on scala.swing.TabbedPane.pages:
The definition of this class is:
class TabbedPane extends Component with Publisher {
object pages extends BufferWrapper[Page] {
def +=
}
}
I can't figure out the syntax for overriding any...
First note the inflammatory subject title is a quotation made about the manifesto of a UK political party in the early 1980s. This question is subjective but it is a genuine question, I've made it CW and I'd like some opinions on the matter.
Despite whatever my wife and coworkers keep telling me, I don't think I'm an idiot: I have a goo...
Ive got a Scala program that downloads and parses html. I got the links to the image files form the html, Now I need to transfer those images to my hard drive. Im wondering what the best Scala method I should use.
my connection code:
import java.net._
import java.io._
import _root_.java.io.Reader
import org.xml.sax.InputSource
import ...
Is there something I've got wrong with the following fragment:-
object Imp {
implicit def string2Int(s: String): Int = s.toInt
def f(i: Int) = i
def main(args: Array[String]) {
val n: Int = f("666")
}
}
I get the following from the 2.8 compiler:-
Information:Compilation completed with 1 error and 0 warnings
Information:...
I currently have
def list(node: NodeSeq): NodeSeq = {
val all = Thing.findAll.flatMap({
thing => bind("thing", chooseTemplate("thing", "entry", node),
"desc" -> Text(thing.desc.is),
"creator" -> thing.creatorName.getOrElse("UNKNOWN"),
"delete" -> SHtml.link("/test", () => delete(thing), Text("delete"...
The scala type Nothing represents (as I understand it) the bottom of the type hierarchy, also denoted by the symbol ⊥. That is, Nothing is a sub-type of any given type. The requirement for a Nothing type is explained well by James Iry for those of us without a theoretical background in type theory!
So my question is, if Nothing is a sub...
I've been curious about the impact of not having an explicit primary constructor in Scala, just the contents of the class body.
In particular I suspect that the private or protected constructor pattern, i.e. controlling construction through the companion object or another class or object's methods might not have an obvious implementati...
I'm parsing some xml, and given a particular node, I'm trying to figure out which one of these it is:
An element with nested elements
<theElement><nestedElement>foobar</nestedElement></theElement>
An element with text/data in it
<theElement>foobar</theElement>
I've tried checking the length of Node.text, but Node.text returns "foob...
Hello
I'm going to work on comparing around 300 binary files using Scala, bytes-by-bytes, 4MB each. However, judging from what I've already done, processing 15 files at the same time using java.BufferedInputStream tooks me around 90 sec on my machine so I don't think my solution would scale well in terms of large number of files.
Ideas...
Hi,
I'm impressed with twitter and investigating to use Scala for a new large scale web project with Hibernate and Wicket. What do you think about Scala, and should I use it instead of Java ?
EDIT: And, do you think google's Noop, Fan or Scala can take the leadership from Java in the near future, which one have chance in your opinion ? ...
I have a function in Scala, and the same function in JavaScript, but I don't think it is in a functional style.
def drawSurroundingTriangles(startx : Double, starty : Double, width : Double) {
var newwidth = width/2;
var newstartx = startx + newwidth / 2;
var newstarty = starty - newwidth;
drawTriangle(newstartx, newstarty, newwidth...