Scala
Learn Scala by typing expressive, functional code.
Practice Scala's blend of OO and functional by typing it: pattern matching, case classes, immutable collections, for-comprehensions, and higher-order functions. Each snippet is idiomatic Scala, and an AI tutor explains every line — how a match deconstructs a case class, why immutability simplifies reasoning — so the paradigm and the keystrokes land together.
Progress0 / 686 solved · 0/50 sections
best wpm
0
avg wpm
0
accuracy
0%
runs
0
level
1
rating
1000
Run Scala on your machine
1. Install the toolchain
brew install scala # (needs a JDK)2. Save your code as hello.scala, then compile & run
scala hello.scalaprogress by section
1Fundamentals0/9start →
2Strings In Depth0/19start →
3Values & References0/16start →
4Slices & Arrays0/18Unlock →
5Data structures0/10Unlock →
6Iterators0/20Unlock →
7Traits0/20Unlock →
Abstract methodConcrete methodsMixin compositionExtension methodsOperator: +OrderedTrait parametersapply for indexingGiven conversionGeneric traitOperator: * by scalarUnary operatorOrdering type classShow type classUsing clauseAbstract type memberContext boundNumeric type classSelf typesStackable traits
8Generics0/20Unlock →
Generic classGeneric enumGeneric methodTwo type parametersUpper bound <:Context boundType class default valueGeneric extension methodIntersection type boundGeneric over iterablesLower bound >:Generic class with methodsGeneric minsummon a givenContravariance -ACovariance +AGeneric with a key functiongiven / using type classF-bounded polymorphismOpaque type
9Lifetimes0/20Unlock →
Immutable valMutable varBlock scopeDefault argumentsFinal constantif is an expressionImmutable collectionsClosure captures a valfor-comprehension scopeLazy valNested definitionsShadowingtry/finally cleanupBy-name parameterClosure captures a varMethod to function valueLazy runs onceReturning a closureBy-name re-evaluatesUsing for resources
10Closures0/20Unlock →
A lambdaExplicit types & block bodyCapturing the environmentFunction type annotationMultiple parametersCallbacksCapturing an immutable valueEta-expansionCapturing in a filterFunction as an argumentFunctions drive iteratorssortWith with a lambdaCurryingMutating captured statePartial applicationReturning a functionA stateful closureReturn different functionsA list of functionscompose & andThen
11Pattern Matching0/20Unlock →
Literals and wildcardCase class deconstructionMatch an Eithermatch as an expressionMatch an OptionOr-patternsRanges via guardsDestructure tuplesPositional deconstructionBinding with @Match a Scala 3 enumMatch guardsBind the head, keep the lastMatch a TryType patternsList patternsMatch a list's shapeSealed trait exhaustive matchLoop while a pattern matchesNested patterns
12Error Handling0/20Unlock →
assert an invariantThrow an exceptionCustom exceptionrequire a preconditiontry / catch / finallyTry.getOrElseKeep only successesTry combinatorsTry.mapTry: Success / FailureTry.recoverfor-comprehension over Eithermap the error sideMatch on error variantsEither for typed errorsTry.flatMapfor-comprehension over TryUsing for cleanupException cause chainingCollect into an Either
13Option & Result0/20Unlock →
14Conversions0/15Unlock →
15Collection Conversions0/19Unlock →
16Math0/14Unlock →
17Encoding0/22Unlock →
String to bytesASCII checks and caseBase64 decodeBase64 encodeBytes to StringChar to code pointChar digit valueBinary, octal, hex formattingBig-endian bytesList code pointsEscape control charsHex encodeLittle-endian bytesBytes vs charsParse a number in a baseURL decodeURL encodeLossy UTF-8 decodeCaesar cipherHex decodeROT13XOR cipher
18Random0/20Unlock →
Coin flipSeed from the clockPick a random elementNumber in a rangeShuffle a collectionRandom f64 in [0, 1)Random UUIDRandom alphanumeric stringWeighted true/falseRandom bytesRandom enum variantNormal distributionA linear congruential generatorPassword generatorReproducible sequencesCryptographic randomnessAn xorshift generatorRoll many diceSample k without replacementWeighted choice
19Data I/O0/18Unlock →
Parse CSV into rowsTab-separated valuesBuild a CSV stringSelect one columnCSV into a number matrixSplit off the headerWhitespace-separated matrixRead a data fileSerialize records to CSVSkip blanks and commentsPrint an aligned tableWrite CSV to a fileWrite a matrix as textAppend a rowParse key=value configRound-trip write then readStream lines from a fileDrop unparseable rows
20Linear Algebra0/21Unlock →
Matrix shapeDot productScalar multiplyA matrix of zerosElementwise addArgmax of a vectorFlatten a matrixIdentity matrixOne-hot encodeTraceTransposeStack rows (vstack)ReLU and sigmoidApply a function elementwiseColumn sums and meansCosine similarityMatrix times vectorMatrix multiplyMin-max normalize columnsSoftmaxStandardize columns (z-score)
21Text Processing0/16Unlock →
22Date & Time0/12Unlock →
23Memory0/12Unlock →
24Modules0/20Unlock →
import a memberAn object as a namespaceConstants in an objectAn enum in an objectGrouped importimport with rename (as)Nested objectsPublic vs privateWildcard importA case class in an objectA companion objectA private helperA package-level functionA small utility objectPrivate field, public getterRe-export with exportFlatten a deep pathimport a givenprivate[pkg] visibilityA trait in an object
25Macros0/20Unlock →
assertPrint variantsAn inline defString interpolatorsExtension methodsf-string formattinginline with an argumentMap from pairsVariadic sumA collection builderA derives clauseinline ifCapturing a literalCompile-time errorconstValueA custom interpolatorType classes with given/usingOpaque typessummonInlinetransparent inline
26Testing0/20Unlock →
assert with a messageAssert values differAn assertEq helperA check helperMultiple checksTesting string outputA truth tableAsserting on a collectionExpected exceptionTesting a failureA test helperTesting a throw pathTesting a methodTesting an OptionScaladoc plus a checkAssert on the messageComparing floatsrequire for preconditionsTable-driven testsTesting with Try
27Algorithms0/8Unlock →
28Sorting Algorithms0/12Unlock →
29Expression Parsing0/6Unlock →
30Idioms0/9Unlock →
31OOP & Traits0/8Unlock →
32Trait Objects0/14Unlock →
33Design Patterns0/14Unlock →
35File I/O0/6Unlock →
36Filesystem0/18Unlock →
37Networking0/16Unlock →
38Concurrency0/7Unlock →
39Unsafe & FFI0/14Unlock →
40Commands0/14Unlock →
41Array0/10Unlock →
43String0/10Unlock →
45Interval0/5Unlock →
46Linked List0/6Unlock →
47Tree0/14Unlock →
Maximum Depth of Binary TreeInvert Binary TreeSame TreeLowest Common Ancestor of a BSTBinary Tree Level Order TraversalSubtree of Another TreeImplement Trie (Prefix Tree)Kth Smallest Element in a BSTValidate Binary Search TreeAdd and Search WordConstruct Binary Tree from Preorder and InorderBinary Tree Maximum Path SumSerialize and Deserialize Binary TreeWord Search II