Programming in Scala: Updated for Scala 2.12

By Bill Venners

Scala is an object-oriented programming language for the Java VirtualMachine. as well as being object-oriented, Scala can also be afunctional language, and combines the easiest ways to OO andfunctional programming.

In Italian, Scala skill a stairway, or steps. certainly, Scala helps you to step as much as a programming atmosphere that comes with the superior fresh pondering in programming language layout whereas additionally letting youuse your whole current Java code.

Artima is especially happy to submit a brand new version of the best-sellingbook on Scala, written via the clothier of the language, Martin Odersky.Co-authored through Lex Spoon and invoice Venners, this publication takes astep-by-step educational method of instructing you Scala. beginning with thefundamental components of the language, Programming in Scala introducesfunctional programming from the practitioner's point of view, anddescribes complex language good points that may make you a greater, moreproductive developer.

Show description

Preview of Programming in Scala: Updated for Scala 2.12 PDF

Best Java books

Mastering Lambdas: Java Programming in a Multicore World (Oracle Press)

The Definitive advisor to Lambda Expressions gaining knowledge of Lambdas: Java Programming in a Multicore global describes how the lambda-related gains of Java SE eight will permit Java to satisfy the demanding situations of next-generation parallel architectures. The e-book explains tips on how to write lambdas, and the way to exploit them in streams and in assortment processing, delivering code examples all through.

Mastering JavaFX 8 Controls (Oracle Press)

Layout and install High-Performance JavaFX Controls carry state of the art functions with visually lovely UIs. gaining knowledge of JavaFX eight Controls presents transparent directions, unique examples, and ready-to-use code samples. how to paintings with the most recent JavaFX APIs, configure UI elements, instantly generate FXML, construct state-of-the-art controls, and successfully practice CSS styling.

Data Abstraction and Problem Solving with Java: Walls and Mirrors (3rd Edition)

The 3rd version of facts Abstraction and challenge fixing with Java: partitions and Mirrors employs the analogies of partitions (data abstraction) and Mirrors (recursion) to educate Java programming layout recommendations, in a manner that starting scholars locate obtainable. The e-book has a student-friendly pedagogical method that rigorously money owed for the strengths and weaknesses of the Java language.

Java Software Solutions: Foundations of Program Design (7th Edition)

Java software program recommendations teaches a starting place of programming innovations to foster well-designed object-oriented software program. Heralded for its integration of small and massive real looking examples, this all over the world best-selling textual content emphasizes construction stable problem-solving and layout abilities to write down fine quality courses.

Extra info for Programming in Scala: Updated for Scala 2.12

Show sample text content

Even if, the concept that of a functionality in Scala is extra common than a mode. Scala’s alternative routes to specific services could be defined within the following sections. eight. 2 neighborhood capabilities the development of the processFile process within the past part proven an incredible layout precept of the useful programming sort: courses will be decomposed into many small capabilities that every do a well-defined activity. person features are usually relatively small. the benefit of this kind is that it provides a programmer many construction blocks that may be flexibly composed to do more challenging issues. every one construction block may be easy adequate to be understood separately. One challenge with this method is that each one the helper functionality names can pollute this system namespace. within the interpreter this isn't rather a lot of an issue, yet as soon as services are packaged in reusable periods and items, it’s fascinating to conceal the helper services from consumers of a category. they typically don't make experience separately, and also you frequently are looking to continue adequate flexibility to delete the helper capabilities for those who later rewrite the category a unique means. In Java, your major instrument for this goal is the personal technique. This private-method strategy works in Scala to boot, as is proven in directory eight. 1, yet Scala deals an extra technique: you could outline features inside of different capabilities. similar to neighborhood variables, such neighborhood services are noticeable purely of their enclosing block. Here’s an instance: def processFile(filename: String, width: Int) { def processLine(filename: String, width: Int, line: String) { if (line. size > width) println(filename +": "+ line) } val resource = resource. fromFile(filename) for (line <- resource. getLines()) { processLine(filename, width, line) } } conceal · evaluate · Contents · speak about · recommend · word list · Index 186 Section eight. 2 bankruptcy eight · capabilities and Closures during this instance, we refactored the unique LongLines model, proven in directory eight. 1, by way of reworking inner most technique, processLine, right into a neighborhood functionality of processFile. to take action we got rid of the non-public modifier, which may in simple terms be utilized (and is simply wanted) for tactics, and positioned the definition of processLine contained in the definition of processFile. As a neighborhood functionality, processLine is in scope inside of processFile, yet inaccessible outdoor. Now that processLine is outlined inside of processFile, although, one other development turns into attainable. realize how filename and width are handed unchanged into the helper functionality? this isn't useful, simply because neighborhood features can entry the parameters in their enclosing functionality. you could simply use the parameters of the outer processLine functionality, as proven in directory eight. 2: import scala. io. resource item LongLines { def processFile(filename: String, width: Int) { def processLine(line: String) { if (line. size > width) println(filename +": "+ line) } val resource = resource. fromFile(filename) for (line <- resource. getLines()) processLine(line) } } directory eight. 2 · LongLines with a neighborhood processLine functionality.

Download PDF sample

Rated 4.78 of 5 – based on 22 votes