Scala Tutorial - People

3y ago
137 Views
10 Downloads
1.66 MB
116 Pages
Last View : Today
Last Download : 3m ago
Upload by : Grady Mosby
Transcription

Scala Tutorial

SCALA TUTORIALSimply Easy Learning by tutorialspoint.comtutorialspoint.comi

ABOUT THE TUTORIALScala TutorialScala is a modern multi-paradigm programming language designed to express common programmingpatterns in a concise, elegant, and type-safe way. Scala has been created by Martin Odersky and hereleased the first version in 2003.Scala smoothly integrates features of object-oriented and functional languages. This tutorial gives a greatunderstanding on Scala.AudienceThis tutorial has been prepared for the beginners to help them understand programming Language Scalain simple and easy steps. After completing this tutorial, you will find yourself at a moderate level ofexpertise in using Scala from where you can take yourself to next levels.PrerequisitesScala Programming is based on Java, so if you are aware of Java syntax, then it's pretty easy to learnScala. Further if you do not have expertise in Java but you know any other programming language like C,C or Python, then it will also help in grasping Scala concepts very quickly.Copyright & Disclaimer Notice Allthe content and graphics on this tutorial are the property of tutorialspoint.com. Any content fromtutorialspoint.com or this tutorial may not be redistributed or reproduced in any way, shape, or formwithout the written permission of tutorialspoint.com. Failure to do so is a violation of copyright laws.This tutorial may contain inaccuracies or errors and tutorialspoint provides no guarantee regarding theaccuracy of the site or its contents including this tutorial. If you discover that the tutorialspoint.com siteor this tutorial content contains some errors, please contact us at webmaster@tutorialspoint.comTUTORIALS POINTSimply Easy Learning

Table of ContentScala Tutorial . 2Audience . 2Prerequisites . 2Copyright & Disclaimer Notice . 2Scala Overview . 8Scala is object-oriented: . 8Scala is functional:. 8Scala is statically typed: . 8Scala runs on the JVM: . 8Scala can Execute Java Code: . 9Scala vs Java: . 9Scala Web Frameworks: . 9Scala Environment Setup . 10Installing Scala on Windows: . 10STEP (1): JAVA SETUP: . 10STEP (2): SCALA SETUP: . 10Installing Scala on Mac OS X and Linux . 11STEP (1): JAVA SETUP: . 11STEP (2): SCALA SETUP: . 11Scala Basic Syntax . 13First Scala Program: . 13INTERACTIVE MODE PROGRAMMING: . 13SCRIPT MODE PROGRAMMING: . 13Basic Syntax: . 14Scala Identifiers: . 15ALPHANUMERIC IDENTIFIERS . 15OPERATOR IDENTIFIERS . 15MIXED IDENTIFIERS . 15LITERAL IDENTIFIERS . 15Scala Keywords: . 15Comments in Scala . 16Blank Lines and Whitespace: . 16Newline Characters: . 16Scala Packages: . 16Scala Data Types . 18Scala Basic Literals: . 18INTEGER LITERALS . 19TUTORIALS POINTSimply Easy Learning

FLOATING POINT LITERALS . 19BOOLEAN LITERALS. 19SYMBOL LITERALS . 19CHARACTER LITERALS. 19STRING LITERALS . 19MULTI-LINE STRINGS . 19THE NULL VALUE . 20ESCAPE SEQUENCES: . 20Scala Variables . 21Variable Declaration . 21Variable Data Types: . 21Variable Type Inference: . 22Multiple assignments: . 22Variable Types:. 22FIELDS: . 22METHOD PARAMETERS: . 22LOCAL VARIABLES: . 22Scala Access Modifiers . 23Private members: . 23Protected members: . 23Public members: . 24Scope of protection:. 24Scala Operators . 25Arithmetic Operators:. 25Example: . 25Relational Operators:. 26Example: . 27Logical Operators: . 27Example: . 27Bitwise Operators: . 28Example . 29Assignment Operators: . 30Example: . 30Operator Precedence in Scala:. 31Scala IF ELSE Statements . 33The if Statement: . 33SYNTAX: . 33EXAMPLE:. 34The if.else Statement: . 34TUTORIALS POINTSimply Easy Learning

SYNTAX: . 34EXAMPLE: . 34The if.else if.else Statement: . 35SYNTAX: . 35EXAMPLE:. 35Nested if.else Statement: . 36SYNTAX: . 36EXAMPLE:. 36Scala Loop Types . 37while loop . 38Syntax: . 38Flow Diagram: . 38Example: . 39do while loop . 39Syntax: . 39Flow Diagram: . 40Example: . 40for loop . 41The for Loop with Ranges . 41Example: . 41The for Loop with Collections . 42Example: . 43The for Loop with Filters . 43Example: . 43The for Loop with yield: . 44Example: . 44Loop Control Statements: . 45break statement . 45Syntax: . 45Flow Diagram: . 46Example: . 46Breaking Nested Loops: . 47Example: . 47Infinite Loop: . 48Scala Functions . 49Function Declarations: . 49Function Definitions: . 49Calling Functions: . 50Scala Closures . 57TUTORIALS POINTSimply Easy Learning

Scala Strings . 58Creating Strings: . 58String Length: . 59Concatenating Strings: . 59Creating Format Strings: . 60String Methods: . 60Scala Arrays. 64Declaring Array Variables: . 64Processing Arrays: . 65Multi-Dimensional Arrays: . 66Concatenate Arrays: . 66Create Array with Range: . 67Scala Arrays Methods: . 68Scala Collections. 69Basic Operations on List: . 70Concatenating Lists: . 71Creating Uniform Lists: . 72Tabulating a Function: . 72Reverse List Order: . 72Scala List Methods: . 73Basic Operations on Set: . 76Concatenating Sets: . 76Find max, min elements in Set: . 77Find common values in Sets:. 77Scala Set Methods: . 78Basic Operations on Map: . 81Concatenating Maps. 81Print Keys and Values from a Map: . 82Check for a Key in Map: . 82Scala Map Methods: . 83Iterate over the Tuple: . 86Convert to String:. 87Swap the Elements:. 87Using getOrElse() Method: . 88Using isEmpty() Method: . 89Scala Option Methods: . 89Find Min & Max valued Element: . 91Find the length of the Iterator:. 91Scala Iterator Methods: . 92TUTORIALS POINTSimply Easy Learning

Example: . 94Scala Classes & Objects . 96Extending a Class:. 97Singleton objects: . 98Scala Traits . 100When to use traits?. 101Scala Pattern Matching . 102Matching Using case Classes:. 103Scala Regular Expressions . 105Forming regular expressions: . 106Regular-expression Examples: . 107Scala Exception Handling . 110Throwing exceptions: . 110Catching exceptions: . 110The finally clause: . 111Scala Extractors . 112Pattern Matching with Extractors: . 113Scala Files I/O. 114Reading line from Screen: . 114Reading File Content: . 115TUTORIALS POINTSimply Easy Learning

1CHAPTERScala OverviewScala, short for Scalable Language, is a hybrid functional programming language. It was created by MartinOdersky and it was first released in 2003.Scala smoothly integrates features of object-oriented and functional languages and Scala is compiled to run on theJava Virtual Machine. Many existing companies, who depend on Java for business critical applications, are turningto Scala to boost their development productivity, applications scalability and overall reliability.Here is the important list of features, which make Scala a first choice of the application de

tutorialspoint.com or this tutorial may not be redistributed or reproduced in any way, shape, or form without the written permission of tutorialspoint.com. Failure to do so is a violation of copyright laws. This tutorial may contain inaccuracies or errors and tutorialspoint provides no guarantee regarding the

Related Documents:

Getting Started in Scala scala Runs compiled scala code Or without arguments, as an interpreter! scalac - compiles fsc - compiles faster! (uses a background server to minimize startup time) Go to scala-lang.org for downloads/documentation Read Scala: A Scalable Language

Java Scala OO features Enough Scala functional features to use use the Scala API in Apache Spark Full-blown functional programming: Lambda calculus, category theory, closures, monads, functors, actors, promises, futures, combinators, functional design patterns, full type system, library construction techniques, reactive

Functional Programming Scala Reduced defects rate Easier maintenance (tests, refactoring) Local reasoning Mathematical rigor We're hiring great people We're still learning It's fun! Functional Programming Scala. Payment-processing Destination Queue - Transaction is

This document is a tutorial introduction to Chisel (Constructing Hardware In a Scala Embedded Lan-guage). Chisel is a hardware construction language embedded in the high-level programming language Scala. At some point we will provide a proper refer-ence manual, in addition to more tutorial examples. In the meantime, this document along with a .

Scala enables you to use all the classes of the Java SDK and also your own custom Java classes, or your favorite Java open source projects. Scala can do Concurrent & Synchronize processing Scala allows you to express general programming patterns in an effective way. It reduces the number of lines and helps the programmer to code in a type-safe way.

Gli accordi prendono nome dal grado della scala su cui sono formati (es. settima di dominante, settima di sensibile, accordo di . sottodominante). I gradi della scala hanno le seguenti denominazioni: Gli accordi principali sono quelli di tonica, dominante e sottodominante: da soli sono sufficienti per armonizzare tutta la scala. Numero di note

Applicato allo strumento il risultato sarà questo: Puoi quindi costruire una scala blues partendo da qualsiasi N.F. e applicando il seguente modello: Scala pentatonica minore di C Scala pentatonica minore di C Aggiungi la 5 Ag

Thank you for choosing the scala rider G9 Bluetooth communication and entertainment system for motorcycle helmets. This manual will help you set up, configure and operate the scala rider G9. If you have purchased the