I just found this web page comparing some code written in Scala, C# and Go. I am astonished to see how close Scala and Go code looks like, much more than Scala code compared to C# code.
So my question is: What are the most significant differences between Scala and Go?
...
All,
I'm doing some image manipulation in Scala by making use of BufferedImages and Raster objects. I am attempting to get all the pixels in the buffered image with the following code.
val raster = f.getRaster()
// Preallocating the array causes ArrayIndexOutOfBoundsException .. http://forums.sun.com/thread.jspa?threadID=5297789
// R...
In what situations should abstract types be preferred over type parameters?
...
I have read about Scala but have not been able to do comparative analysis of other web programming frameworks on the basis of:
maintainability (does the Scala language facilitate the maintainability of such a web framework, compared to, say, a Php-based one?),
scalability (what OS is best adapted for a Scala wab server to be scalable?)...
Hi everyone,
I am interested in extending my website to provide a service which involves users "check in" in my university's campus. Since Location Based Services (LBS) is pretty new, and there are not much literature around that could provide relevant interests to this matter, I have the following questions to ask:
First, I know that I...
I have a base class that comes from a Java library, whose code I cannot modify. This class (A) has an empty method (b) which should have been declared as abstract instead:
class A {
def b { }
}
I extend this class in Scala and override the method to make it abstract:
abstract class AA extends A {
override def b
}
Now I implemen...
Often there's no need to pay any attention to implicit arguments in Scala, but sometimes it's very helpful to understand how the compiler is automatically providing them. Unfortunately, this understanding seems to be hard to obtain!
Is there a general method to discover how an implicit parameter has been provided, in a given piece of...
Hello,
I'm quite new to Scala programming language, and was trying something out stucked in my mind while I was following the lecture notes at here.
I think I couldn't really understand how cons operator works, here are some things I tried:
I've created a pseudo-random number generator, then tried to create a list of one random value...
def mainCaller() = {
val name = "xyz"
someList.foreach { u:Map => foo(name, u) }
}
def foo(name:String)(map:Map): Unit = {
//match case....
//recursive call to foo in each case where name remains same, but map changes
}
how can I write foo as a partially applied function, where I dont have to pass name in every recursive call...
I want to get an image from a response but I don't know how to get the OutputStream.
I know in jsp, it is:
response.getOutputStream()
but what is it in liftweb ?
Thanks a lot.
...
I've seen BASIC and Apache Camel DSLs in Scala, and they're just fantastic. Any more examples of such DSLs?
...
I find myself using a lot of nested maps, e.g a Map[Int, Map[String, Set[String]]], and I'd like to have new Maps, Sets, etc. created automatically when I access a new key. E.g. something like the following:
val m = ...
m(1992)("foo") += "bar"
Note that I don't want to use getOrElseUpdate here if I don't have to because it gets pretty...
I have this case class define:
class Protocol(protocol:String)
object Protocol {
def apply(protocol:String) :Protocol = {
protocol.toUpperCase match {
case "HTTP" => Http()
case "HTTPS" => Https()
case "Ftp" => Ftp()
case "Mail" =>Mail()
case other => new Protocol(other)
}
}
}
cas...
I'm embarrassed to ask this, but I cannot figure out how to run a scala program that is defined to be within a package.
Example:
package foo.bar {
object Hello {
def main(args:Array[String]) {
println("Hello")
}
}
}
After compiling the Hello.scala file, I get the expected directory structure
-- ...
AKA doing something at set intervals.
For example, let's say I want to scan a certain directory every 60 seconds.
In Java, I would use a ScheduledExecutorService like so:
Executor pool = Executors.newScheduledThreadPool(10)
pool.scheduleAtFixedRate(scanner, 0, 60, TimeUnit.SECONDS)
and that works fine.
The thing is, I'm thinking I'...
I want to know how can I do following things in scala?
Connect to a postgreSQL database.
Write SQL queries like SELECT , UPDATE etc. to modify a table in that database.
I know that in python I can do it using PygreSQL but how to do these things in scala?
...
In Scala, how do I define an anonymous function which takes a variable number of arguments?
scala> def foo = (blah:Int*) => 3
<console>:1: error: ')' expected but identifier found.
def foo = (blah:Int*) => 3
^
...
Hi chaps,
I'm trying to design a couple of classes that inherit a partial function, but I don't seem to be able to get the syntax quite right. My superclass looks like this:
abstract class Controller {
val react:PartialFunction[Event,Unit]
}
And the subclass looks like:
class BoardRendererController(val renderer:BoardRenderer, ...
I have a Map[String, String] and want to concatenate the values to a single string.
I can see how to do this using a List...
scala> val l = List("te", "st", "ing", "123")
l: List[java.lang.String] = List(te, st, ing, 123)
scala> l.reduceLeft[String](_+_)
res8: String = testing123
fold* or reduce* seem to be the right approach I just...
I noticed this interesting syntax the other day for specifying the type parameters for a Scala class.
scala> class X[T, U]
defined class X
scala> new (Int X Int)
res1: X[Int,Int] = X@856447
Is there a name for this sort of syntax? What's a good use case for it?
...