class Foo {
@SomeAnnotation
var bar: String = _
}
@SomeAnnotation is a Java annotation (so it is kept at runtime) with runtime retention and Method target. The code compiles, but at runtime the bar() and bar_=() methods that the compiler generated are not annotated.
Assuming this is not a bug, is there a clean way of annotating t...
Hello guys,
I want to use Stream class in scala to repeat a given list infinitely.
For example the list (1,2,3,4,5) I want to create a stream that gives me (1,2,3,4,5,1,2,3,4,5,1,2,3....)
So that I can wrap the take operation. I know this can be implemented in other ways, but I wanna do it this way for some reason, just humor me :)
S...
I am building a site that has a lot in common with a person-on-person chess site. I was thinking of using Rails for the front-end(User Registration, Navigation, etc) and something like Scala or Erlang for the engine(Game state and maybe AI). I was wondering -
Is this a good situation to use that type of design?
How exactly would be be...
In Scala, how can i add a container trait (like Traversable[Content]) to another one that extends the container (and thus has limited visibility of its content ?
For example, the code below tries to define a trait WithIter for a container requiring Traversable (of course, i have in fact other things in Container).
import scala.collecti...
object TestEnum extends Enumeration{
val One = Value("One")
val Two,Three= Value
}
println(TestEnum.One.getClass)
println(TestEnum.One.getClass.getDeclaringClass)//get Enumeration
So my question is how to get Class[TestEnum] from TestEnum.One?
Thanks.
...
I've got a set of rows in a database, and I'd like to provide an interface to spin through them like this:
def findAll: Iterable[MyObject]
Where we don't require having all the instances in memory at once. In C# you can easily create generators like this using yield, the compiler takes care of converting code that loops through the r...
Could you share your experience of using Scala and Wicket together? Do they fit naturally to each other? Do you get advantage of using Scala (and FP) with Wicket over using Java? Why did (would) you prefer Wicket over Lift?
...
Something like
def option[T](v: T): Option[T] = if (v == null) None else Some(v)
I'm perfectly happy defining this utility method myself, but just wondered if it already exists somewhere.
...
Is their an equivalent to C#'s Expression API in scala?
For example, I would like to have a lambda like this:
(Foo) => Foo.bar
and be able to access "bar" in the function it is passed to.
...
I'd love it if there is an awesome native Scala library for SNMP like there is Dispatch for HTTP but I can't find one. Is there one? Baring that, should I use a Java library like SNMP4J? What I want to do is so simple that it almost seems like overkill: I just want to listen on a given port for SNMP messages (which will always be in the ...
Given the following traits and class. Why does this compile? Can this be actually used for something?
trait Container {
type A
}
trait AnotherContainer[B]{
def x(b : B) : B
}
trait Mixed extends Container with AnotherContainer[Container#A]
class Impl extends Mixed{
def x(a : Container#A) = a
}
new Impl().x _
scala> new ...
I've been asked to run a workshop and coding dojo soon for people to try out Scala and try to build something with it. The attendees are all going to be new to Scala, and could come from any of a number of languages (I'm presuming they can code in at least one mainstream language - I'm including syntax comparisons with Java, C#, Python a...
Case classes in Scala are standard classes enhanced with pattern-matching, equals, ... (or am I wrong?). Moreover they require no "new" keyword for their instanciation. It seems to me that they are simpler to define than regular classes (or am I again wrong?).
There are lots of web pages telling where they should be used (mostly about p...
Why is the + operator for List deprecated in Scala?
http://www.scala-lang.org/docu/files/api/scala/List.html#%2B%28B%29
...
In Scala, what does
trait A <: B
mean? Is it just the same as
trait A extends B
?
Edited to add: I'm familiar with the syntax for type parameters, and what <: means in that context. However, in the above example it would seem to me that A is the name of the trait being declared, not a type parameter.
...
Is it possible to provide an implementation of a method using a function object/value? I would like to write something in the spirit of:
abstract class A { def f(x:Int) : Int }
class B extends A { f = identity }
...
I'm trying to save data parced with Lifts' Json data extraction and save it to the database(via mapper) but I cannot find where to connect the snippit to the mapper. The code looks like this.
Here is a test snippit.
package com.testjson.snippet
import dispatch._
import net.liftweb.json.JsonParser._
import java.io.{ByteArrayOutputStrea...
I know this is an exact duplicate, but a year has gone by and Scala seems to be a fast moving thing, so I figure it might be acceptable to ask again:
What is the best IDE for Scala development right now?
...
Hi all,
How to use the scala dispatch library to send a post request to the server in the Lift ?
I want to send a post request to the external server get some information and then use this information in
my web app.
Is there any demo code can be applied that will be appreciated !
Thanks
Cheers.
Neil
...
I've been reading up about Akka and it really seems nice. Can you somehow set it up to work with Apache Mina or similar techs? I.e not only use it in conjunction with servlets.
...