Questions tagged [scala]

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: an advanced static type system with type inference; function types; pattern-matching; implicit parameters and conversions; operator overloading; full interoperability with Java; concurrency

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 and styles. Its key features are:

  • Static typing
  • Advanced type system with type inference and declaration-site variance
  • Function types (including anonymous) which support lexical closures
  • Pattern-matching
  • Implicit parameters and conversions which support the typeclass and enrich-my-library patterns
  • Mixin composition
  • Full interoperability with Java
  • Powerful concurrency constructs
  • Advanced language constructs such as delimited continuations and an experimental macro system

For more information, see the official Scala Introduction and Scala Documentation.

To search for Scala symbols such as => in Stack Overflow, you can use symbolhound search.

To search Scala documentation, you can use scalex.

A community list of available libraries is available at Awesome Scala

There is Scala Library Index by Scala Center: Scaladex.

Free Scala programming books and guides

Stack Overflow Scala Tutorial

  1. Introduction to Scala
  1. Variables/values
  1. Methods
  1. Literals, statements and blocks
  1. Loops/recursion
  1. Data structures / Collections
  1. For-comprehension
  1. Enumeration
  1. Pattern matching
  1. Classes, objects and types
  1. Packages, imports and visibility identifiers
  1. Inheritance
  1. Extractors
  1. Case classes
  1. Parameterized types
  1. Traits
  1. Self references
  1. Error handling
  1. Type handling
  1. Annotations
  1. Functions/Function literals
  1. Type safety
  1. Implicits
  1. Reflection
  1. Enrich-my-library pattern (formerly known as pimp-my-library)
  1. Concurrency overview
  2. Actors
  1. Use Java from Scala and vice versa
  1. XML literals
  • Explanation
  1. Scala Swing
  1. Type Programming
  1. Functional Scala

Further learning

  1. Learning Resources
  1. REPL
  1. Working with scalac and scala
  1. Operator precedence
  1. Scala style
  1. Functional Programming Principles in Scala, a functional programming course on Coursera taught by Martin Odersky, the creator of Scala.
  2. Principles of Reactive Programming, a reactive functional programming course on Coursera taught by Martin Odersky, Erik Meijer, Roland Kuhn.
  3. Parallel Programming, a parallel programming course on Coursera taught by Viktor Kuncak and Aleksandar Prokopec.
111781 questions
29
votes
2 answers

How to check that an array contains a particular value in Scala 2.8?

I've got an array A of D unique (int, int) tuples. I need to know if the array contains (X, Y) value. Am I to implement a search algorithm myself or there is a standard function for this in Scala 2.8? I've looked at documentation but couldn't find…
Ivan
  • 63,011
  • 101
  • 250
  • 382
29
votes
1 answer

Reading multiple files from S3 in Spark by date period

Description I have an application, which sends data to AWS Kinesis Firehose and this writes the data into my S3 bucket. Firehose uses "yyyy/MM/dd/HH" format to write the files. Like in this sample S3 path: s3://mybucket/2016/07/29/12 Now I have a…
V. Samma
  • 2,558
  • 8
  • 30
  • 34
29
votes
7 answers

Scala Option[Future[T]] to Future[Option[T]]

How can I convert Option[Future[T]] to Future[Option[T]] in scala? I want to use it in: val customerAddresses = for { a <- addressDAO.insert(ca.address) // Future[Address] ia <- ca.invoiceAddress.map(addressDAO.insert) //…
Michał Jurczuk
  • 3,728
  • 4
  • 32
  • 56
29
votes
6 answers

Merge Spark output CSV files with a single header

I want to create a data processing pipeline in AWS to eventually use the processed data for Machine Learning. I have a Scala script that takes raw data from S3, processes it and writes it to HDFS or even S3 with Spark-CSV. I think I can use multiple…
V. Samma
  • 2,558
  • 8
  • 30
  • 34
29
votes
1 answer

Spark Scala: How to transform a column in a DF

I have a dataframe in Spark with many columns and a udf that I defined. I want the same dataframe back, except with one column transformed. Furthermore, my udf takes in a string and returns a timestamp. Is there an easy way to do this? I tried val…
mt88
  • 2,855
  • 8
  • 24
  • 42
29
votes
3 answers

Scalamock 3. Mock overloaded method without parameter

I couldn't find any documentation that explains how to mock overloaded methods that take no arguments in scalamock e.g public boolean isInfoEnabled(Marker marker); public boolean isInfoEnabled(); To mock the function that takes the Marker, one can…
user2715478
  • 1,273
  • 12
  • 17
29
votes
2 answers

Constructing simple Scala case classes from Strings, strictly without boiler-plate

I seek succinct code to initialize simple Scala case classes from Strings (e.g. a csv line): case class Person(name: String, age: Double) case class Book(title: String, author: String, year: Int) case class Country(name: String, population: Int,…
Perfect Tiling
  • 661
  • 4
  • 13
29
votes
5 answers

How to checkpoint DataFrames?

I'm looking for a way to checkpoint DataFrames. Checkpoint is currently an operation on RDD but I can't find how to do it with DataFrames. persist and cache (which are synonyms for each other) are available for DataFrame but they do not "break the…
Daniel Shields
  • 1,452
  • 1
  • 12
  • 7
29
votes
1 answer

Spark: How to map Python with Scala or Java User Defined Functions?

Let's say for instance that my team has choosen Python as the reference language to develop with Spark. But later for performance reasons, we would like to develop specific Scala or Java specific librairies in order to map them with our Python code…
prossblad
  • 688
  • 1
  • 7
  • 11
29
votes
2 answers

A binding to play.api.db.DBApi was already configured, evolutions and injector error with play-slick

I want to introduce slick to my play project, so I add the following dependencies to build.sbt: "com.typesafe.play" %% "play-slick" % "1.0.1" withSources(), "com.typesafe.play" %% "play-slick-evolutions" %…
ttt
  • 3,934
  • 8
  • 46
  • 85
29
votes
1 answer

How Clojure's agents compare to Scala's actors?

I wrote a simulation of the Ring network topology in Scala (source here) (Scala 2.8 RC7) and Clojure (source here) (Clojure 1.1) for a comparison of Actors and Agents. While the Scala version shows almost constant message exchange rate as I…
Abhinav Sarkar
  • 23,534
  • 11
  • 81
  • 97
29
votes
11 answers

How to extract best parameters from a CrossValidatorModel

I want to find the parameters of ParamGridBuilder that make the best model in CrossValidator in Spark 1.4.x, In Pipeline Example in Spark documentation, they add different parameters (numFeatures, regParam) by using ParamGridBuilder in the Pipeline.…
Mohammad
  • 1,006
  • 2
  • 15
  • 29
29
votes
5 answers

How to convert DataFrame to Json?

I have a huge JSON file, a small part from it as follows: { "socialNews": [{ "adminTagIds": "", "fileIds": "", "departmentTagIds": "", ........ ........ "comments": [{ "commentId": "", …
ashish.garg
  • 291
  • 1
  • 3
  • 7
29
votes
1 answer

Why does Scala use a ForkJoinPool to back its default ExecutionContext?

In Scala you can use a global ExecutionContext if you don't need to define your own by importing scala.concurrent.ExecutionContext.Implicits.global. My question is why ForkJoinPool was chosen for this executor instead of ThreadPoolExecutor. My…
Rag
  • 6,405
  • 2
  • 31
  • 38
29
votes
1 answer

Is Slick 3.0 reactive/asynchronous at the database driver level? For which databases?

Slick has historically relied on JDBC drivers, which internally block waiting for socket I/O in response to queries. Every outstanding database call requires a thread to block on a socket; hence, it's not really reactive in the same sense as…
Ed Staub
  • 15,480
  • 3
  • 61
  • 91
1 2 3
99
100