Questions tagged [scala-2.7]

For issues relating to development with Scala, version 2.7.

Scala is a general purpose programming language principally targeting the Java Virtual Machine. Designed to express common programming patterns in a concise, elegant, and type-safe way, it fuses both imperative and functional programming styles. Its key features are: statically typed; advanced type-system with type inference; function types; pattern-matching; implicit parameters and conversions; operator overloading; full interop with Java.

See for more information.

15 questions
90
votes
10 answers

Converting a Java collection into a Scala collection

Related to Stack Overflow question Scala equivalent of new HashSet(Collection) , how do I convert a Java collection (java.util.List say) into a Scala collection List? I am actually trying to convert a Java API call to Spring's SimpleJdbcTemplate,…
oxbow_lakes
  • 133,303
  • 56
  • 317
  • 449
49
votes
9 answers

How to use Scala in IntelliJ IDEA (or: why is it so difficult to get a working IDE for Scala)?

I recently gave up trying to use Scala in Eclipse (basic stuff like completion doesn't work). So now I'm trying IntelliJ. I'm not getting very far. I've been able to edit programs (within syntax highlighting and completion... yay!). But I'm unable…
Alex R
  • 11,364
  • 15
  • 100
  • 180
24
votes
2 answers

Calling a method on the superclass in a self-typed trait in scala

I'm trying to create a trait that, when mixed in, will replace the default definition of a method with one that calls the original method and then manipulates the result. Here's what I'm trying to do: class Foo { def bar() : String = "Foos…
Daniel Martin
  • 23,083
  • 6
  • 50
  • 70
23
votes
4 answers

Can I use for-comprehenion / yield to create a map in Scala?

Can I "yield" into a Map? I've tried val rndTrans = for (s1 <- 0 to nStates; s2 <- 0 to nStates if rnd.nextDouble() < trans_probability) yield (s1 -> s2); (and with ,…
aioobe
  • 413,195
  • 112
  • 811
  • 826
11
votes
1 answer

idiomatic property changed notification in scala?

I'm trying to find a cleaner alternative (that is idiomatic to Scala) to the kind of thing you see with data-binding in WPF/silverlight data-binding - that is, implementing INotifyPropertyChanged. First, some background: In .Net WPF or silverlight…
Jeremy Bell
  • 5,253
  • 5
  • 41
  • 63
10
votes
3 answers

Immutable Map implementation for huge maps

If I have an immutable Map which I might expect (over a very short period of time - like a few seconds) to be adding/removing hundreds of thousands of items from, is the standard HashMap a bad idea? Let's say I want to pass 1Gb of data through the…
oxbow_lakes
  • 133,303
  • 56
  • 317
  • 449
7
votes
4 answers

Stuck at "Hello World" with IntelliJ IDEA 9.0.1 for Scala

I've been using Eclipse since 2.x and IDEs in general for over 20 years (since Turbo Pascal and Turbo C in the late '80s!). (that preamble is supposed to imply, "I'm not an idiot" ... but doesn't sound so smart as I read it... LOL :-] ) Now I'm…
Alex R
  • 11,364
  • 15
  • 100
  • 180
5
votes
3 answers

How to extract valid email from larger string in Scala

My scala version 2.7.7 Im trying to extract an email adress from a larger string. the string itself follows no format. the code i've got: import scala.util.matching.Regex import scala.util.matching._ val Reg =…
Luigimax
  • 546
  • 1
  • 5
  • 12
4
votes
1 answer

Object initialization sequence in scala in an inherent hierarchy

I'm new to scala from java and confused by sequence of object initialization of scala in an inherent hierarchy. IIRC, in Java, if an object of sub-class is initialized, constructor of its base class is invoked before any code of its own constructor.…
Summer_More_More_Tea
  • 12,740
  • 12
  • 51
  • 83
4
votes
1 answer

Scala type inference failure on "? extends" in Java code

I have the following simple Java code: package testj; import java.util.*; public class Query { private static List l = Arrays.asList(1, "Hello", 3.0); private final Class clazz; public static…
oxbow_lakes
  • 133,303
  • 56
  • 317
  • 449
4
votes
1 answer

Strange behavior: Scala Actors 2.7.7 vs. 2.8-Snapshot

I'm an 18 years old trainee and I'm discovering scala which I like very much :-). To get familiar with the scala actors I wrote a small simulation with some gears and one controller. The ActorApplication creates N gears with random speed. The…
meip
  • 404
  • 3
  • 7
2
votes
1 answer

initialising a 2-dim Array in Scala

(Scala 2.7.7:) I don't get used to 2d-Arrays. Arrays are mutable, but how do I specify a 2d-Array which is - let's say of size 3x4. The dimension (2D) is fixed, but the size per dimension shall be initializable. I tried this: class Field (val rows:…
user unknown
  • 35,537
  • 11
  • 75
  • 121
2
votes
2 answers

Illegal inheritance compilation error using Scala 2.7.7 and LIFT 1.1-SNAPSHOT

I am using JDK 1.6.0_16, and Scala 2.7.7, compiling with maven. I do mvn clean compile and I get four errors, but they are identical, in different models: [ERROR] C:\Users\owner\workspace\ResumeApp\src\main\scala\jblack\resumeapp\lift\ …
James Black
  • 41,583
  • 10
  • 86
  • 166
1
vote
2 answers

Looking for example of type class usage that will work in Scala 2.7.7 and 2.8 scripts

Hi I'm looking for a quick example of type class usage in Scala that will work in both 2.7.7 and 2.8 environments. All of the examples that I've seen only work in 2.8, but I've been told that type classes are implementable in 2.7.7 as well. The only…
klactose
  • 1,190
  • 2
  • 9
  • 26
0
votes
2 answers

Scala found List and SeqProjection, when required Seq and Set

Sitting with the following error: TestCaseGenerator.scala:47: error: type mismatch; found : List[(State, Seq.Projection[State])] required: Seq[(State, Set[State])] new LTS(Map(rndTrans: _*), Map(rndLabeling: _*)) ^ one error…
aioobe
  • 413,195
  • 112
  • 811
  • 826