Giter Club home page Giter Club logo

cheatsheet's Introduction

cheatsheet

scala

  • It’s a high-level language

  • It’s statically typed

  • Its syntax is concise but still readable — we call it expressive

  • It supports the object-oriented programming (OOP) paradigm

  • It supports the functional programming (FP) paradigm

  • It has a sophisticated type inference system

  • Scala code results in .class files that run on the Java Virtual Machine (JVM)

  • It’s easy to use Java libraries in Scala

  • Strings and built-in numeric types

  • Packaging and imports

  • How to use Java collections classes in Scala

  • How to use Java libraries in Scala

  • How to build Scala projects

  • How to perform unit testing in Scala

  • How to write Scala shell scripts

  • Maps, Sets, and other collections classes

  • Object-oriented programming

  • Functional programming

  • Concurrency with Futures

  • More …

collection

0 to 10 by 2

1 to 2 contains 2

for

for e <- seq {}

for e <- seq if xx {}

for e <- seq yield {}

foreach

map

filter

pattern match

def fn(x: Any): String = x match { case 1 => "one" case 2 | 3 => "two or three" case v if v < 5 => "four" case v: String => s"str $v" case _ => "?" }

future

  • You construct futures to run tasks off of the main thread
  • Futures are intended for one-shot, potentially long-running concurrent tasks that eventually return a value
  • A future starts running as soon as you construct it
  • A benefit of futures over threads is that they come with a variety of callback methods that simplify the process of working with concurrent threads, including the handling of exceptions and thread management
  • Handle the result of a future with methods like onComplete, or combinator methods like map, flatMap, filter, andThen, etc.
  • The value in a Future is always an instance of one of the Try types: Success or Failure
  • If you’re using multiple futures to yield a single result, you’ll often want to combine them in a for-expression

cheatsheet's People

Contributors

bookinstock avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.