,

Scala for the Impatient

Paperback Engels 2023 9780138033651
Verwachte levertijd ongeveer 9 werkdagen

Samenvatting

Scala 3--A Clear, Concise Guide

Scala 3 is concise, consistent, flexible, robust, and efficient, but there's a lot to learn and navigating features and improvements can be challenging. Scala for the Impatient, Third Edition, is a complete yet concise guide that reflects the major enhancements of Scala 3, from improved syntax and revamped type system to powerful contextual abstractions.

This indispensable tutorial offers a faster, easier pathway for learning today's Scala. Horstmann--author of the programming classic, Core Java--covers everything working developers need to know, focusing on hands-on solutions, not academic theory. Given the size and scope of Scala 3, there's plenty to cover but it's presented in small chunks organized for quick access and easy understanding, with plenty of practical insights and focused sample code. Get started quickly with Scala 3 interpreter, syntax, tools, and current usage Master core language features: functions, arrays, maps, tuples, packages, imports, exception handling, and more Design and build better object-oriented code with Scala 3 Use Scala for real-world programming tasks: working with files, regular expressions, and processes Work with higher-order functions and the powerful Scala collections library Create concurrent programs with Scala futures Understand the Scala type system, including revamped enums, intersection and union types, and enhanced type inference Use contextual abstractions to easily extend class hierarchies, enrich existing classes, perform automatic conversions, and elegantly hide tedious details Apply advanced "power tools" such as annotations and given values Discover how to "program with types," analyzing and generating types at compile time Get a taste of what's now possible with Scala macros

If you're a Java, Python, C++, or C# programmer who's new to Scala or functional programming--or even if you've already used earlier versions of Scala--this guide will help you write code that's more robust, more efficient, and more secure.

Register your book for convenient access to downloads, updates, and/or corrections as they become available. See inside book for details.

Specificaties

ISBN13:9780138033651
Taal:Engels
Bindwijze:Paperback

Lezersrecensies

Wees de eerste die een lezersrecensie schrijft!

Inhoudsopgave

<p>Foreword to the First Edition xix<br>Preface xxi<br>About the Author xxv</p> <p><strong>Chapter 1: The Basics 1</strong><br>1.1 The Scala Interpreter 1<br>1.2 Declaring Values and Variables 4<br>1.3 Commonly Used Types 5<br>1.4 Arithmetic and Operator Overloading 7<br>1.5 More about Calling Methods 8<br>1.6 The apply Method 9<br>1.7 Scaladoc 11<br>Exercises 14</p> <p><strong>Chapter 2: Control Structures and Functions 17</strong><br>2.1 Conditional Expressions 18<br>2.2 Statement Termination 20<br>2.3 Block Expressions and Assignments 21<br>2.4 Input and Output 22<br>2.5 Loops 23<br>2.6 More about the for Loop 25<br>2.7 Functions 27<br>2.8 Default and Named Arguments 29<br>2.9 Variable Arguments 30<br>2.10 The Main Function 31<br>2.11 Functions without Parameters 31<br>2.12 Lazy Values 32<br>2.13 Exceptions 33<br>Exercises 36</p> <p><strong>Chapter 3: Working with Arrays 39</strong><br>3.1 Fixed-Length Arrays 39<br>3.2 Variable-Length Arrays: Array Buffers 40<br>3.3 Traversing Arrays and Array Buffers 41<br>3.4 Transforming Arrays 42<br>3.5 Common Algorithms 44<br>3.6 Deciphering Scaladoc 45<br>3.7 Multidimensional Arrays 46<br>3.8 Interoperating with Java 47<br>Exercises 48</p> <p><strong>Chapter 4: Maps, Options, and Tuples 51</strong><br>4.1 Constructing a Map 52<br>4.2 Accessing Map Values 52<br>4.3 Updating Map Values 53<br>4.4 Iterating over Maps 54<br>4.5 Linked and Sorted Maps 54<br>4.6 Interoperating with Java 55<br>4.7 The Option Type 56<br>4.8 Tuples 57<br>4.9 Zipping 59<br>Exercises 59</p> <p><strong>Chapter 5: Classes 63</strong><br>5.1 Simple Classes and Parameterless Methods 63<br>5.2 Properties with Getters and Setters 65<br>5.3 Properties with Only Getters 67<br>5.4 Private Fields 68<br>5.5 Auxiliary Constructors 69<br>5.6 The Primary Constructor 70<br>5.7 Nested Classes 73<br>Exercises 74</p> <p><strong>Chapter 6: Objects and Enumerations 77</strong><br>6.1 Singletons 78<br>6.2 Companion Objects 78<br>6.3 Objects Extending a Class or Trait 79<br>6.4 The apply Method 80<br>6.5 Application Objects 81<br>6.6 Enumerations 81<br>Exercises 83</p> <p><strong>Chapter 7: Packages, Imports, and Exports 85</strong><br>7.1 Packages 86<br>7.2 Package Scope Nesting 87<br>7.3 Chained Package Clauses 88<br>7.4 Top-of-File Notation 88<br>7.5 Package-Level Functions and Variables 89<br>7.6 Package Visibility 89<br>7.7 Imports 90<br>7.8 Imports Can Be Anywhere 91<br>7.9 Renaming and Hiding Members 91<br>7.10 Implicit Imports 92<br>7.11 Exports 92<br>Exercises 93</p> <p><strong>Chapter 8: Inheritance 97</strong><br>8.1 Extending a Class 98<br>8.2 Overriding Methods 98<br>8.3 Type Checks and Casts 99<br>8.4 Superclass Construction 100<br>8.5 Anonymous Subclasses 101<br>8.6 Abstract Classes 101<br>8.7 Abstract Fields 102<br>8.8 Overriding Fields 102<br>8.9 Open and Sealed Classes 104<br>8.10 Protected Fields and Methods 105<br>8.11 Construction Order 105<br>8.12 The Scala Inheritance Hierarchy 106<br>8.13 Object Equality 109<br>8.14 Multiversal Equality 110<br>8.15 Value Classes 111<br>Exercises 112</p> <p><strong>Chapter 9: Files and Regular Expressions 117</strong><br>9.1 Reading Lines 118<br>9.2 Reading Characters 118<br>9.3 Reading Tokens and Numbers 119<br>9.4 Reading from URLs and Other Sources 120<br>9.5 Writing Files 120<br>9.6 Visiting Directories 120<br>9.7 Serialization 121<br>9.8 Process Control 122<br>9.9 Regular Expressions 124<br>9.10 Regular Expression Groups 126<br>Exercises 126</p> <p><strong>Chapter 10: Traits 129</strong><br>10.1 Why No Multiple Inheritance? 129<br>10.2 Traits as Interfaces 131<br>10.3 Traits with Concrete Methods 132<br>10.4 Traits for Rich Interfaces 133<br>10.5 Objects with Traits 133<br>10.6 Layered Traits 134<br>10.7 Overriding Abstract Methods in Traits 135<br>10.8 Concrete Fields in Traits 136<br>10.9 Abstract Fields in Traits 137<br>10.10 Trait Construction Order 138<br>10.11 Trait Constructors with Parameters 139<br>10.12 Traits Extending Classes 140<br>10.13 What Happens under the Hood 141<br>10.14 Transparent Traits 143<br>10.15 Self Types 143<br>Exercises 145</p> <p><strong>Chapter 11: Operators 149</strong><br>11.1 Identifiers 150<br>11.2 Infix Operators 151<br>11.3 Unary Operators 152<br>11.4 Assignment Operators 153<br>11.5 Precedence 153<br>11.6 Associativity 154<br>11.7 The apply and update Methods 155<br>11.8 The unapply Method 155<br>11.9 The unapplySeq Method 157<br>11.10 Alternative Forms of the unapply and unapplySeq Methods 158<br>11.11 Dynamic Invocation 159<br>11.12 Typesafe Selection and Application 162<br>Exercises 163</p> <p><strong>Chapter 12: Higher-Order Functions 169</strong><br>12.1 Functions as Values 170<br>12.2 Anonymous Functions 170<br>12.3 Parameters That Are Functions 171<br>12.4 Parameter Inference 172<br>12.5 Useful Higher-Order Functions 173<br>12.6 Closures 174<br>12.7 Interoperability with Lambda Expressions 175<br>12.8 Currying 176<br>12.9 Methods for Composing, Currying, and Tupling 177<br>12.10 Control Abstractions 178<br>12.11 Nonlocal Returns 179<br>Exercises 180</p> <p><strong>Chapter 13: Collections 183</strong><br>13.1 The Main Collections Traits 184<br>13.2 Mutable and Immutable Collections 185<br>13.3 Sequences 187<br>13.4 Lists 188<br>13.5 Sets 189<br>13.6 Operators for Adding or Removing Elements 190<br>13.7 Common Methods 193<br>13.8 Mapping a Function 195<br>13.9 Reducing, Folding, and Scanning 197<br>13.10 Zipping 200<br>13.11 Iterators 201<br>13.12 Lazy Lists 202<br>13.13 Interoperability with Java Collections 204<br>Exercises 205</p> <p><strong>Chapter 14: Pattern Matching 209</strong><br>14.1 A Better Switch 210<br>14.2 Guards 211<br>14.3 Variables in Patterns 211<br>14.4 Type Patterns 212<br>14.5 The Matchable Trait 213<br>14.6 Matching Arrays, Lists, and Tuples 214<br>14.7 Extractors 216<br>14.8 Patterns in Variable Declarations 217<br>14.9 Patterns in for Expressions 218<br>14.10 Case Classes 219<br>14.11 Matching Nested Structures 221<br>14.12 Sealed Classes 222<br>14.13 Parameterized Enumerations 223<br>14.14 Partial Functions 224<br>14.15 Infix Notation in case Clauses 225<br>Exercises 226</p> <p><strong>Chapter 15: Annotations 231</strong><br>15.1 What Are Annotations? 232<br>15.2 Annotation Placement 232<br>15.3 Annotation Arguments 233<br>15.4 Annotations for Java Features 234<br>15.5 Annotations for Optimizations 236<br>15.6 Annotations for Errors and Warnings 238<br>15.7 Annotation Declarations 239<br>Exercises 241</p> <p><strong>Chapter 16: Futures 245</strong><br>16.1 Running Tasks in the Future 246<br>16.2 Waiting for Results 248<br>16.3 The Try Class 249<br>16.4 Callbacks 250<br>16.5 Composing Future Tasks 251<br>16.6 Other Future Transformations 253<br>16.7 Methods in the Future Object 255<br>16.8 Promises 257<br>16.9 Execution Contexts 258<br>Exercises 259</p> <p><strong>Chapter 17: Type Parameters 263</strong><br>17.1 Generic Classes 264<br>17.2 Generic Functions 264<br>17.3 Bounds for Type Variables 265<br>17.4 Context Bounds 266<br>17.5 The ClassTag Context Bound 267<br>17.6 Multiple Bounds 267<br>17.7 Type Constraints 267<br>17.8 Variance 268<br>17.9 Co- and Contravariant Positions 270<br>17.10 Objects Can't Be Generic 271<br>17.11 Wildcards 272<br>17.12 Polymorphic Functions 273<br>Exercises 274</p> <p><strong>Chapter 18: Advanced Types 277</strong><br>18.1 Union Types 277<br>18.2 Intersection Types 278<br>18.3 Type Aliases 279<br>18.4 Structural Types 281<br>18.5 Literal Types 283<br>18.6 The Singleton Type Operator 284<br>18.7 Abstract Types 286<br>18.8 Dependent Types 287<br>18.9 Abstract Type Bounds 289<br>Exercises 290</p> <p><strong>Chapter 19: Contextual Abstractions 295</strong><br>19.1 Context Parameters 296<br>19.2 More about Context Parameters 297<br>19.3 Declaring Given Instances 299<br>19.4 Givens in for and match Expressions 301<br>19.5 Importing Givens 302<br>19.6 Extension Methods 303<br>19.7 Where Extension Methods Are Found 304<br>19.8 Implicit Conversions 306<br>19.9 Rules for Implicit Conversions 307<br>19.10 Importing Implicit Conversions 308<br>19.11 Context Functions 309<br>19.12 Evidence 311<br>19.13 The @implicitNotFound Annotation 312<br>Exercises 313</p> <p><strong>Chapter 20: Type-Level Programming 317</strong><br>20.1 Match Types 318<br>20.2 Heterogeneous Lists 319<br>20.3 Literal Type Arithmetic 322<br>20.4 Inline Code 323<br>20.5 Type Classes 326<br>20.6 Mirrors 328<br>20.7 Type Class Derivation 330<br>20.8 Higher-Kinded Types 332<br>20.9 Type Lambdas 334<br>20.10 A Brief Introduction into Macros 335<br>Exercises 339</p> <p>Index 343</p>

Managementboek Top 100

Rubrieken

Populaire producten

    Personen

      Trefwoorden

        Scala for the Impatient