How to define “type disjunction” (union types)?

One way that has been suggested to deal with double definitions of overloaded methods is to replace overloading with pattern matching: object Bar { def foo(xs: Any*) = xs foreach { case _:String => println(“str”) case _:Int => println(“int”) case _ => throw new UglyRuntimeException() } } This approach requires that we surrender static type … Read more

What Scala web-frameworks are available? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done … Read more

What do

I can see in the API docs for Predef that they’re subclasses of a generic function type (From) => To, but that’s all it says. Um, what? Maybe there’s documentation somewhere, but search engines don’t handle “names” like “<:<” very well, so I haven’t been able to find it. Follow-up question: when should I use … Read more

difference between foldLeft and reduceLeft in Scala

I have learned the basic difference between foldLeft and reduceLeft foldLeft: initial value has to be passed reduceLeft: takes first element of the collection as initial value throws exception if collection is empty Is there any other difference ? Any specific reason to have two methods with similar functionality? 8 Answers 8