Removing nodes from XML
I want to produce an XML document from another, filtering subnodes that match a specified criterion. How should I do that? ...
I want to produce an XML document from another, filtering subnodes that match a specified criterion. How should I do that? ...
hi, if i have a trait: trait MyTrait { def doSomething = { println("boo") } } I can add it to a class with "extends": class MyClass extends MyTrait { .... } or i can add it to a new object when i construct it: var o = new MyOtherClass with MyTrait o.doSomething but... can i add it to an existing ob...
I have reached this far: implicit def collectionExtras[A](xs: Iterable[A]) = new { def zipWith[B, C, That](ys: Iterable[B])(f: (A, B) => C)(implicit cbf: CanBuildFrom[Iterable[A], C, That]) = { val builder = cbf(xs.repr) val (i, j) = (xs.iterator, ys.iterator) while(i.hasNext && j.hasNext) { builder += f(i.next, j.ne...
When I run my project for the first time during an SBT session, it throws the following exception when trying to access a MySQL database: java.lang.NoClassDefFoundError: scala/Ordered When I run it again (and any time after it, during the same SBT session), it throws a different one: java.sql.SQLException: No suitable driver fo...
Hi, is it possible to nest following specs test code "ClassX" should { "throw an IllegalArgumentException if n < 0" in { ClassX(-1) must throwA[IllegalArgumentException] } "throw an IllegalArgumentException if n > 50" in { ClassX(51) must throwA[IllegalArgumentException] } "throw an IllegalArgumentException if n == 35...
What's the syntax to set immutable hashmap contents on initialization? For example, if I was willing to hardcode an array, I'd write: val a = Array (0, 1, 2, 3) What's the analogue for immutable hashmaps (say I want it to contain 0->1 and 2->3 pairs) (in Scala 2.8)? ...
Is there a way to have full standard Scala library documentation off-line? ...
I've defined multiple constructors, with some default argument values in all of them. Looks correct (I can't see any ambiguity), but Scala (2.8) compiler complains: multiple overloaded alternatives of constructor define default arguments Does it mean that I can't define default values for overloaded constructors at all? Let me ill...
I have a problem with specifying types for enumeration values (instances of scala.Enumeration) in functions. This originally arises from my need to serialize enumeration objects in database, but I've extracted the problematic code in the following example: object EnumerationTypes { class EnumerationProcessor[E <: Enumeration](enum: E...
Say I have got following two case classes: case class Address(street: String, city: String, state: String, zipCode: Int) case class Person(firstName: String, lastName: String, address: Address) and the following instance of Person class: val raj = Person("Raj", "Shekhar", Address("M Gandhi Marg", ...
I just found it in the API (http://www.scala-lang.org/api/current/scala/Proxy.html) and would like to see one or two examples along with an explanation what it is good for. ...
I know parallel collections will become available. What form will these take, and what else are we likely to see? ...
is it possible to have a method that takes an arbitrary instance and returns a java.reflection.Proxy or similar that has the same type as the original argument? I guess it should look something like this: def createProxy[S](model: S)(implicit manifest: Manifest[S]): S = {...} or this def createProxy[S, T<:S](model: S)(implicit manif...
I have a small conundrum when it comes to Scala properties. Various blogs and tutorials tell me that this: class Something { var foo = 1 } ...can be specified as... class Something { private var _field = 1 def foo = _field def foo_(foo: Int) = _field = foo } This makes perfect sense to me, when doing assignment th...
For example GeneralType is a class or a trait extended by many more specific types, including, to say, SpecificType. A function takes an argument of type GeneralType, and then whant's no know if the actual argument passed is a SpecificType instance and act accordingly (use its special fields/methods) if it is. How to code this in Sca...
I want to be be able to manipulate objects in memory in my Java app interactively for debugging purposes. I would quite like to do this using Scala's 2.8 interpreter, taking advantages of its features like tab-completion. How do I do this? ...
I was thinking of building an app on android with Scala instead of the regular Java (or the equivalent I guess). Is it worth it? Any problems and unnecessary headaches? ...
sealed abstract trait HList case class :+:[H, T <: HList](head: H, tail: T) extends HList { def :+:[T](v: T) = new :+:(v, this) } case object HNil extends HList { def :+:[T](v: T) = new :+:(v, this) } object HListExpt { def main(args: Array[String]) { val me: String :+: Int :+: Symbol :+: HNil.type = "Rahul" :+: 20 :+: 'Male...
Hi all, I've delopped some Scala code to control the lifecycle of MySQL server. The code runs fine on Windows XP, but fails under Windows 2008 R2 standard with the following exception: Exception in thread "main" java.io.IOException: Cannot run program "mysql" (in directory ".\bin"): CreateProcess error=2, The system cannot find the fil...
Hello, I am doing a training exercise in Scala and getting this val reassignment error. I don't see where I am reassigning a new value to a val class personTest { val alf = Person("Alf", 30, List(EmailAddress("[email protected]"))) val fredrik = Person("Fredrik", 33, List(EmailAddress("[email protected]"), EmailAddress("fvr@...