Hi,
I'll give some C-style "bracket" pseudo-code to show what I'd like to express in another way:
for (int i = 0; i < n; i++) {
if (i == 3 || i == 5 || i == 982) {
assertTrue( isCromulent(i) );
} else {
assertFalse( isCromulent(i) );
}
}
The for loop is not very important, that is not the point of my...
EDIT 2:
I managed to achieve the type safety I wanted in my exercise with RomanNumerals using a combination of mixins and type parameters with the code below. In essence what it does is after importing everything in RomanNumerals I am able to write L X V I, but not L L or X L X cause then I get a type mismatch compiler error (since tho...
Hi
I wrote this in scala and it won't compile:
class TestDoubleDef{
def foo(p:List[String]) = {}
def foo(p:List[Int]) = {}
}
the compiler notify:
[error] double definition:
[error] method foo:(List[String])Unit and
[error] method foo:(List[Int])Unit at line 120
[error] have same type after erasure: (List)Unit
I know JVM has no...
EDIT: Rewrote the question. Added bounty as its important for me. The final hint with which i can get findByAttributes to work (without reimplementing it in subclasses) will get my points.
In my app i'm doing typesafe database queries with the new JPA2 Criteria Query. Therefore I have a trait DAO which should be (re)usable for ALL entit...
The first thing described in the howto (http://www.assembla.com/wiki/show/scala-ide/Developing_for_Android) is this:
Step 1: Create the ant files for your project:
cd
android update project --target 1 --path .
which yields 'command not found'. I'm in the 'workspace/name_of_my_app/' folder.
How do i get to have the 'android' command...
I'm trying to use the java jcommander library from Scala. The java JCommander class has multiple constructors:
public JCommander(Object object)
public JCommander(Object object, ResourceBundle bundle, String... args)
public JCommander(Object object, String... args)
I want to to call the first constructor that takes no var...
I have this class in Scala:
object Util {
class Tapper[A](tapMe: A) {
def tap(f: A => Unit): A = {
f(tapMe)
tapMe
}
def tap(fs: (A => Unit)*): A = {
fs.foreach(_(tapMe))
tapMe
}
}
implicit def tapper[A](toTap: A): Tapper[A] = new Tapper(toTap)
}
Now,
"aaa".tap(_.trim)
doesn't compile,...
Possible Duplicate:
Which programming languages can I use on Android Dalvik?
Mostly, Android applications are written in Java. But i heard that its also possible to use Scala or some other languages. And I also read that it's possible to include native C/C++ code.
Is there a refernce/list available that shows which languages ...
Possible Duplicate:
In Scala, how can I subclass a Java class with multiple constructors?
Hello all clever people
I'm currently having a little problem where I need to invoke different super methods based on which constructor I invoke.
In short it is something like this:
class HelpfulJList(model: ListModel) extends JList(mo...
Hi all,
In Python, a dictionary can be constructed from an iterable collection of tuples:
>>> listOfTuples = zip(range(10), [-x for x in range(10)])
>>> listOfTuples
[(0, 0), (1, -1), (2, -2), (3, -3), (4, -4), (5, -5), (6, -6), (7, -7), (8, -8), (9, -9)]
>>> theDict = dict(listOfTuples)
>>> theDict
{0: 0, 1: -1, 2: -2, 3: -3, 4: -4, 5...
Last time I had to deal with Java was 2005 and I forgot almost everything about it since then.
Today I need to build a GUI app on the top of Java. I guess it is better to use one of Scala/Groovy/Clojure languages.
The question is: which of them is better for desktop GUI programming? My program will transform and display a series of jpe...
Hi! I'm trying to create web app on pure Scala code. I use last version of Google plugin for Eclipse to create App Engine Web project. After it I add Scala nature to project. I rewrite standart Java servlet generated by Google plugin to Scala servlet version. Everything fine, no scala code errors found. But Eclipse show me some errors in...
I have
Eclipse 3.5.2
Scala 2.8.0 final (inc latest Scala IDE for Eclipse)
Maven integration for Eclipse
Maven 2.2.1
.project and .classpath files generated by maven-eclipse-plugin
I'm using Scala to write Specs BDD tests for my Java code and the setup above is working very nicely so far. However, I have one puzzling problem and I wou...
The actor model is nicely described by Gul Agha on his technical report, "Actors: a model of concurrent computation in distributed systems".
On page 49 he explains the "become" command:
become <expression>
After calling "become X", an actor will forward all his messages to another actor's mailbox (X).
I'm not sure, however, how this...
According to http://www.assembla.com/wiki/show/scala-ide/Troubleshooting in order to have the Scala Eclipse plugin to work with eclipse 3.5 you must desintall your Spring-IDE pluging since the latter deactive the JDT Weaving. I had to do so.
Do you know any effective way to circumvent this, I'm an active Spring developer, for obvious re...
It seems like the support for printing arrays is somewhat lacking in Scala. If you print one, you get the default garbage you'd get in Java:
scala> val array = Array.fill(2,2)(0)
array: Array[Array[Int]] = Array(Array(0, 0), Array(0, 0))
scala> println(array)
[[I@d2f01d
Furthermore, you cannot use the Java toString/deep...
I'm new to Scala and was just reading Scala By Example. In chapter 2, the author has 2 different versions of Quicksort.
One is imperative style:
def sort(xs: Array[Int]) {
def swap(i: Int, j: Int) {
val t = xs(i); xs(i) = xs(j); xs(j) = t
}
def sort1(l: Int, r: Int) {
val pivot = xs((l + r) / 2)
var ...
Let's say I have a function like this (it's only an example, so do not offer me better ways to create 0,1,2,... style array):
def createArray(size: Int): Array[Int] = {
for (i <- 0 until size) yield i
}
But the compiler get upset with some mysterious type mismatch error:
(fragment of compare-images.scala):39: error: type mismatch;
...
Hello All
I'm currently working on a port of a jEdit plugin to write all code in Scala. However Im forced at a certain point to implement my own Comparator.
My simplified code is as follows:
class compare extends MiscUtilities.Compare {
def compare(obj1: AnyRef, obj2: AnyRef): Int = 1
}
The MiscUtilities.Compare has the following ...