HomeSearch

Scala Pages

Dot Net Perls has example pages for many languages, with explanations and code side by side (for easy understanding).
C#F#GoJavaJavaScriptPythonRubyScalaSwiftVB.NETWPF

Map.

Use Maps to look up values with keys. Create a Map and invoke Map functions.Scala Map Examples

2D list.

Create a 2D list by nesting lists within a list. Call Array.ofDim for a 2D array.Scala 2D List, Array Examples: Array.ofDim

Console.

Use console functions like println and printf. Read lines from the console.Scala Console: println, printf and readLine

Convert.

Convert string values to Ints. Change Lists and Maps to strings.Scala Convert: String to Int, List and Array

For loops.

Use the for-loop on a List. Loop over a range of values with the for-to syntax.Scala For to, until, while Loop Examples

Format.

Use the formatted and format methods on format strings to insert values in placeholders.Scala format and formatted Strings

Initialize list.

Initialize Lists with operators and constructors. Use List.empty and newBuilder.Scala Initialize List: List.newBuilder, List.empty

Keywords.

Review Scala keywords and language features. Browse links on these keywords.Scala Keywords

List.

Use List to store Strings and Ints together. Access length and use the for-loop.Scala List Examples

Match.

Use match with cases to test the value of a variable and return another value.Scala Match and Case (List Pattern Matching)

Option.

Return optional values from a function with the Option class. Use None, isDefined, get and getOrElse.Scala Option: None, get and getOrElse

R, Regex.

Use the Regex class to match patterns. Call findFirstMatchIn and other methods.Scala Regex, R Examples: findFirstMatchIn

Range.

Create a range with the to method. Use the by function to specify a step.Scala Range Examples: Start, End and Step

Remove duplicates.

Use the distinct function, along with map, to remove duplicate elements from lists.Scala Remove Duplicates From List: Distinct Example

Set.

Create a Set to store unique elements in a collection. Use contains and intersect.Scala Set Examples: contains, intersect

Slice, substring.

Use the slice function to create substrings and get slices of lists.Scala Slice: Substring, List Slice

Sorted.

Use sorted, and Ordering, to sort an Int list in ascending and descending order.Scala Sorted List Examples: Ordering.Int

Split.

Call split to separate strings on delimiters. Use an Array for multiple delimiter characters.Scala Split String Examples

StringBuilder.

Create a StringBuilder with newBuilder and use append to add strings to it. Call toString to get a string.Scala StringBuilder Examples

Strings.

Use strings and the StringLike functions to process strings. Call capitalize and get lines.Scala String Examples: StringLike

Strip.

Use the stripLineEnd and stripMargin functions to remove characters from strings.Scala Strip Strings: stripLineEnd and stripMargin

Try, exceptions.

Handle exceptions with try, catch and throw. Use case to match exception types.Scala Exception Handling: Try, Catch and Throw

Tuple.

Use tuples to store multiple variables together. Return a tuple from a function.Scala Tuple Examples (Return Multiple Values)

Var, variables.

Create variables and constants with var and val. Fix the reassignment to val error.Scala Var and Val (Variables and Constants)

Vector.

Use Vector from scala.collection.immutable.Vector. Add elements and use Lists with vectors.Scala Vector Examples
Home
Dot Net Perls
© 2007-2019 Sam Allen. All rights reserved. Written by Sam Allen, info@dotnetperls.com.