Showing preview only (463K chars total). Download the full file or copy to clipboard to get everything.
Repository: nadimbahadoor/allaboutscala
Branch: master
Commit: a8732775ca04
Files: 173
Total size: 402.5 KB
Directory structure:
gitextract__67be5e7/
├── .gitignore
├── LICENSE
├── README.md
└── source-code/
└── allaboutscala/
├── .gitignore
├── build.sbt
├── project/
│ ├── build.properties
│ └── plugins.sbt
└── src/
└── main/
└── scala/
└── com/
└── allaboutscala/
└── chapter/
├── eight/
│ ├── Aggregate_Tutorial.scala
│ ├── Collect_Tutorial.scala
│ ├── Diff_Tutorial.scala
│ ├── DropWhile_Tutorial.scala
│ ├── Drop_Tutorial.scala
│ ├── Exists_Tutorial.scala
│ ├── FilterFilterNot_Tutorial.scala
│ ├── Find_Tutorial.scala
│ ├── FlatMap_Tutorial.scala
│ ├── Flatten_Tutorial.scala
│ ├── FoldLeft_Tutorial.scala
│ ├── FoldRight_Tutorial.scala
│ ├── Fold_Tutorial.scala
│ ├── Foreach_Tutorial.scala
│ ├── GroupBy_Tutorial.scala
│ ├── Head_Tutorial.scala
│ ├── Intersect_Tutorial.scala
│ ├── IsEmpty_Tutorial.scala
│ ├── Last_Tutorial.scala
│ ├── Map_Tutorial.scala
│ ├── MaxBy_Tutorial.scala
│ ├── Max_Tutorial.scala
│ ├── MinBy_Tutorial.scala
│ ├── Min_Tutorial.scala
│ ├── MkString_Tutorial.scala
│ ├── NonEmpty_Tutorial.scala
│ ├── Par_Tutorial.scala
│ ├── Partition_Tutorial.scala
│ ├── ReduceLeft_Tutorial.scala
│ ├── ReduceRight_Tutorial.scala
│ ├── Reduce_Tutorial.scala
│ ├── ReverseIterator.scala
│ ├── Reverse_Tutorial.scala
│ ├── ScanLeft_Tutorial.scala
│ ├── ScanRight_Tutorial.scala
│ ├── Scan_Tutorial.scala
│ ├── Size_Tutorial.scala
│ ├── Slice_Tutorial.scala
│ ├── SortBy_Tutorial.scala
│ ├── SortWith_Tutorial.scala
│ ├── Sorted_Tutorial.scala
│ ├── Tail_Tutorial.scala
│ ├── TakeRight_Tutorial.scala
│ ├── TakeWhile_Tutorial.scala
│ ├── Take_Tutorial.scala
│ ├── Transpose_Tutorial.scala
│ ├── Union_Tutorial.scala
│ ├── Unzip3_Tutorial.scala
│ ├── Unzip_Tutorial.scala
│ ├── ViewTutorial.scala
│ ├── WithFilter_Tutorial.scala
│ ├── ZipWIthIndex.scala
│ └── Zip_Tutorial.scala
├── five/
│ ├── ExtendMultipleTraits.scala
│ ├── ExtendTrait_Tutorial.scala
│ ├── TraitDependencyInjectionPartTwo_Tutorial.scala
│ ├── TraitDependencyInjection_Tutorial.scala
│ ├── TraitFactory_Tutorial.scala
│ └── TraitWithTypes_Tutorial.scala
├── four/
│ ├── CaseClassInheritance_Tutorial.scala
│ ├── CaseClass_Tutorial.scala
│ ├── CompanionObjectAsFactory_Tutorial.scala
│ ├── CompanionObjectFields_Tutorial.scala
│ ├── CompanionObject_Tutorial.scala
│ ├── ContraVariance_Tutorial.scala
│ ├── Covariance_Tutorial.scala
│ ├── ExtendClass_Tutorial.scala
│ ├── ImplicitClass_Tutorial.scala
│ ├── PackageObject_Tutorial.scala
│ ├── SimpleClass_Tutorial.scala
│ ├── SingletonObject_Tutorial.scala
│ ├── TypeAlias_Tutorial.scala
│ ├── TypeClass_Tutorial.scala
│ └── package.scala
├── nine/
│ ├── Tutorial_01_Function_With_Future_Return_Type.scala
│ ├── Tutorial_02_Non_Blocking_Future_Result.scala
│ ├── Tutorial_03_Chain_Futures_FlatMap.scala
│ ├── Tutorial_04_Chain_Futures_For_Comprehension.scala
│ ├── Tutorial_05_Future_Option_With_For_Comprehension.scala
│ ├── Tutorial_06_Future_Option_Map.scala
│ ├── Tutorial_07_Composing_Futures.scala
│ ├── Tutorial_08_Future_Sequence.scala
│ ├── Tutorial_09_Future_Traverse.scala
│ ├── Tutorial_10_Future_FoldLeft.scala
│ ├── Tutorial_11_Future_Reduce.scala
│ ├── Tutorial_12_Future_FirstCompletedOf.scala
│ ├── Tutorial_13_Future_Zip.scala
│ ├── Tutorial_14_Future_ZipWith.scala
│ ├── Tutorial_15_Future_AndThen.scala
│ ├── Tutorial_16_Future_Configure_ThreadPool.scala
│ ├── Tutorial_17_Future_Recover.scala
│ ├── Tutorial_18_Future_RecoverWith.scala
│ ├── Tutorial_19_Future_FallbackTo.scala
│ └── Tutorial_20_Future_Promise.scala
├── one/
│ ├── tutorial_04/
│ │ └── HelloWorld.scala
│ ├── tutorial_05/
│ │ └── HelloWorldMain.scala
│ ├── tutorial_06/
│ │ └── HelloWorldWithArguments.scala
│ ├── tutorial_07/
│ │ └── HelloWorldWithArgumentsDebug.scala
│ └── tutorial_10/
│ └── HelloWorldWithScalaLogging.scala
├── seven/
│ ├── MutableArrayBuffer_Tutorial.scala
│ ├── MutableArrayStack_Tutorial.scala
│ ├── MutableArray_Tutorial.scala
│ ├── MutableBitSet_Tutorial.scala
│ ├── MutableHashMap_Tutorial.scala
│ ├── MutableHashSet_Tutorial.scala
│ ├── MutableLinkedHashMap_Tutorial.scala
│ ├── MutableLinkedHashSet_Tutorial.scala
│ ├── MutableListBuffer_Tutorial.scala
│ ├── MutableListMap_Tutorial.scala
│ ├── MutableMap_Tutorial.scala
│ ├── MutableQueue_Tutorial.scala
│ ├── MutableSet_Tutorial.scala
│ ├── MutableSortedSet_Tutorial.scala
│ ├── MutableTreeSet_Tutorial.scala
│ └── PriorityQueue_Tutorial.scala
├── six/
│ ├── ImmutableBitSet_Tutorial.scala
│ ├── ImmutableHashMap_Tutorial.scala
│ ├── ImmutableHashSet_Tutorial.scala
│ ├── ImmutableListMap_Tutorial.scala
│ ├── ImmutableListSet_Tutorial.scala
│ ├── ImmutableList_Tutorial.scala
│ ├── ImmutableMap_Tutorial.scala
│ ├── ImmutableQueue_Tutorial.scala
│ ├── ImmutableSequence_Tutorial.scala
│ ├── ImmutableSet_Tutorial.scala
│ ├── ImmutableSortedSet_Tutorial.scala
│ ├── ImmutableStack_Tutorial.scala
│ ├── ImmutableStream_Tutorial.scala
│ ├── ImmutableTreeMap_Tutorial.scala
│ ├── ImmutableTreeSet_Tutorial.scala
│ └── ImmutableVector_Tutorial.scala
├── three/
│ ├── CreateAndUseFunction_Tutorial.scala
│ ├── FunctionAsValues_Tutorial.scala
│ ├── FunctionByName_Tutorial.scala
│ ├── FunctionCompositionAndThen_Tutorial.scala
│ ├── FunctionCompositionCompose_Tutorial.scala
│ ├── FunctionCurriedParameterGroups_Tutorial.scala
│ ├── FunctionDefinedAsSymbols_Tutorial.scala
│ ├── FunctionHigherOrderAsParameters_Tutorial.scala
│ ├── FunctionRecursiveTailCall_Tutorial.scala
│ ├── FunctionRecursive_Tutorial.scala
│ ├── FunctionTrampoline_Tutorial.scala
│ ├── FunctionWhichIsImplicit_Tutorial.scala
│ ├── FunctionWhichIsNested.scala
│ ├── FunctionWhichIsPartial_Tutorial.scala
│ ├── FunctionWhichIsPolymorphicWithGenericReturnType_Tutorial.scala
│ ├── FunctionWhichIsTyped_Tutorial.scala
│ ├── FunctionWithCallbackParameter_Tutorial.scala
│ ├── FunctionWithImplicitParameters_Tutorial.scala
│ ├── FunctionWithOptionParameters_Tutorial.scala
│ ├── FunctionWithOptionReturnType_Tutorial.scala
│ ├── FunctionWithParameters_Tutorial.scala
│ └── FunctionWithVariableArguments_Tutorial.scala
└── two/
├── tutorial_01/
│ └── VariablesBasics_Tutorial.scala
├── tutorial_02/
│ └── StringInterpolation_Tutorial.scala
├── tutorial_03/
│ └── EscapeCharacter_Tutorial.scala
├── tutorial_04/
│ └── VariablesTypeInference_Tutorial.scala
├── tutorial_05/
│ └── If_Else_Expression_Tutorial.scala
├── tutorial_06/
│ └── ForLoop_Tutorial.scala
├── tutorial_07/
│ └── Range_Tutorial.scala
├── tutorial_08/
│ └── WhileLoop_Tutorial.scala
├── tutorial_09/
│ └── PatternMatching_Tutorial.scala
├── tutorial_10/
│ └── Tuples_Tutorial.scala
├── tutorial_11/
│ └── Option_Tutorial.scala
├── tutorial_12/
│ └── TypeHierarchy_Tutorial.scala
└── tutorial_13/
└── Enumeration_Tutorial.scala
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
*.class
*.log
# sbt specific
.cache
.history
.lib/
dist/*
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project/
# Scala-IDE specific
.scala_dependencies
.worksheet
.idea
================================================
FILE: LICENSE
================================================
Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
[http://www.apache.org/licenses/LICENSE-2.0]
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
================================================
FILE: README.md
================================================
# Source Code For Scala Tutorials From www.allaboutscala.com
## Introduction
The Scala programming language is rapidly growing in popularity! Sadly, most of the online tutorials do not provide a step-by-step guide :(
At www.allaboutscala.com, we provide a complete beginner's tutorial to help you learn Scala in **small**, **simple** and **easy steps**.
- Tutorials are organized such that they allow you to **learn gradually**.
- Tutorials are written by taking into account the **complete beginner**.
- Tutorials will make you proficient with the same professional **tools used by the Scala experts**.
## Get Our Books
### Scala For Beginners
This book provides a **step-by-step** guide for the *complete beginner* to learn Scala. It is particularly useful to *programmers*, *data scientists*, *big data engineers*, *students*, or just about anyone who wants to **get up to speed fast** with Scala (especially within an enterprise context). You get to build a real-world Scala multi-project with Akka HTTP.
You can buy the book at https://leanpub.com/scalaforbeginners/
## Our Online Tutorials
### Scala Introduction: A general overview of Scala
- [1: Introduction](http://allaboutscala.com/tutorials/scala-introduction/)
- [2: What is Scala programming language](http://allaboutscala.com/tutorials/scala-introduction/learn-scala-programming-language/)
- [3: Scala functional programming features and more!](http://allaboutscala.com/tutorials/scala-introduction/scala-functional-programming-features/)
### Chapter 1: Getting familiar with the IntelliJ IDEA
- [1: Introduction](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/)
- [2: Scala Environment Setup – Install Java Development Kit (JDK)](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/scala-environment-setup-install-java-jdk/)
- [3: Scala Environment Setup – How to install the IntelliJ IDE](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/scala-environment-setup-install-intellij-ide/)
- [4: Scala Environment Setup – How to install Scala plugin in IntelliJ](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/scala-environment-setup-install-scala-plugin-intellij/)
- [5: Scala Tutorial – Your first Scala Hello World application](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/scala-tutorial-first-hello-world-application/)
- [6: Where is the main method to launch Scala application](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/where-is-main-method-launch-scala-application/)
- [7: IntelliJ Run Configuration – Running Your Scala application](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/intellij-run-configuration-scala-application/)
- [8: IntelliJ Debug Configuration – Debugging Your Scala Application](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/intellij-debug-configuration-scala-application/)
- [9: IntelliJ Project Structure – Getting Started With Scala Project](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/intellij-project-structure-getting-started-scala-project/)
- [10: IntelliJ Project Structure – Scala Project Classpath](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/intellij-project-structure-scala-project-classpath/)
- [11: IntelliJ Import Dependencies – Getting Started With build.sbt](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/getting-started-sbt-import-dependencies-build-sbt/)
- [12: IntelliJ Import Dependencies – SBT Dependencies And Maven](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/intellij-import-dependencies-sbt-maven/)
- [13: IntelliJ Manage Configurations – Settings, Preferences](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/intellij-manage-configurations-settings-preferences-win-mac/)
- [14: IntelliJ Keyboard Shortcuts – Navigation Shortcuts](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/intellij-keyboard-shortcuts-navigation)
- [15: IntelliJ Keyboard Shortcuts – Search Shortcuts](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/intellij-keyboard-shortcuts-search/)
- [16: IntelliJ Keyboard Shortcuts – Compile, Debug, Run](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/intellij-keyboard-shortcuts-compile-debug-run/)
### Chapter 2: Learning the basic foundation of Scala
- [1: Introduction](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/)
- [2: Scala Basic Tutorial – How To Declare Variables And Types](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-basic-tutorial-declare-variables-types/)
- [3: Scala String Interpolation – Print And Format Variables](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-string-interpolation-print-format-variables/)
- [4: Scala – How To Escape Characters And Create Multi-line String](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-escape-characters-create-multi-line-string/)
- [5: An Overview Of Scala Type Inference](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-overview-scala-type-inference/)
- [6: How To Use If Else Statement And Expression](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-use-if-else-statement-expression/)
- [7: Learn How To Use For Comprehension](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-learn-use-for-comprehension/)
- [8: Learn How To Use Range](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-learn-use-range-inclusive-exclusive/)
- [9: Learn How To Use While And Do While Loop](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-learn-how-to-use-while-and-do-while-loop/)
- [10: Learn How To Use Pattern Matching](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-learn-how-to-use-pattern-matching/)
- [11: Learn How To Use Tuples](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-learn-how-to-use-tuples-pattern-match/)
- [12: Learn How To Use Option – Avoid Null](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-learn-use-option-avoid-null/)
- [13: Learn The Scala Class And Type Hierarchy](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-learn-scala-class-type-hierarchy/)
- [14: Learn How To Create And Use Enumerations](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/learn-to-create-use-enumerations/)
### Chapter 3: Thinking In Terms Of Functions
- [1: Introduction](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/)
- [2: Learn How To Create And Use Functions](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-use-functions/)
- [3: Learn How To Create Function With Parameters](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-function-parameters/)
- [4: Learn How To Use Option In Function Parameters](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-use-option-function-parameters/)
- [5: Learn How To Create Function With Option Return Type](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-function-return-type/)
- [6: Learn How To Create Function With Implicit Parameter](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-function-implicit-parameter/)
- [7: Learn How To Create Implicit Function](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-implicit-function/)
- [8: Learn How To Create Typed Function](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-typed-function/)
- [9: Learn How To Create Polymorphic Function With Generic Return Type](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-polymorphic-function-generic-return-type/)
- [10: Learn How To Create Variable Argument Function](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-variable-argument-function/)
- [11: Learn How To Create Functions As Symbols](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-functions-symbols/)
- [12: Learn How To Create Function Currying With Parameter Groups](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-create-function-currying-parameter-groups/)
- [13: Learn How To Create Higher Order Function - Function As Parameter](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-higher-order-function-parameter/)
- [14: Learn How To Create Higher Order Function - Call By Name Function](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-call-name-function/)
- [15: Learn How To Create Higher Order Function - With Callback Parameter](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-function-callback-parameter/)
- [16: Learn How To Create Function Using The Val Keyword Instead Of Def](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-val-function-val-vs-def/)
- [17: Learn Function Composition Using AndThen](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-function-composition-andthen/)
- [18: Learn Function Composition Using Compose](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-function-composition-compose/)
- [19: Learn How To Create Tail Recursive Function - @annotation.tailrec](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-tail-recursive-function-tailrec-annotation/)
- [20: Learn How To Create Tail Recursive Function - scala.util.control.TailCalls._](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-tail-recursive-function-scala-control-util-tailcalls/)
- [21: Learn How To Create Trampoline Tail Recursive Function Using scala.util.control.TailCalls._](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-trampoline-tail-recursive-function/)
- [22: Learn How To Create Partial Function Using the PartialFunction Trait](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-partial-function-trait/)
- [23: Learn How To Create Nested Function](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-nested-function/)
### Chapter 4: Think you know Object Oriented using classes?
- [1: Introduction](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/)
- [2: Learn How To Create Classes And Objects In Scala](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-create-classes-objects/)
- [3: Learn How To Create And Use Companion Objects](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-create-use-companion-objects/)
- [4: Learn How To Use Companion Objects' Apply Method As A Factory (Class Hierarchy Via Inheritance)](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-companion-objects-factory-apply-method-inheritance/)
- [5: Learn How To Declare Values And Fields In Companion Object](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-declare-value-fields-companion-object/)
- [6: Learn How To Declare And Use Singleton Object](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-declare-use-singleton-objects/)
- [7: Learn How To Define And Use Case Class](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-define-use-case-class/)
- [8: Learn How To Use Type Alias: Type Aliasing Versus Case Class](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-use-type-alias-versus-case-class/)
- [9: Learn How To Use Implicit Class - Extension Methods](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-use-implicit-class-extension-methods/)
- [10: Learn How To Use Package Object](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-package-object/)
- [11: Learn How To Extend Class - Class Inheritance](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-extend-class/)
- [12: Learn How To Extend Case Class - Case Class Inheritance](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-extend-case-class/)
- [13: Learn How To Create Type Class](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-type-class/)
- [14: Learn How To Create Covariance Type Class](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-variance-covariance/)
- [15: Learn How To Create Contra-Variance Type Class](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-variance-contra-variance/)
### Chapter 5: Dependency Injection reinvented using traits
- [1: Introduction](http://allaboutscala.com/tutorials/chapter-5-traits/)
- [2: Learn How To Create And Extend Trait In Scala](http://allaboutscala.com/tutorials/chapter-5-traits/scala-extend-trait/)
- [3: Learn How To Create Trait With Type Parameters](http://allaboutscala.com/tutorials/chapter-5-traits/scala-trait-type-parameters/)
- [4: Learn How To Extend Multiple Traits](http://allaboutscala.com/tutorials/chapter-5-traits/scala-extend-multiple-traits/)
- [5: Learn How To Use Traits For Dependency Injection](http://allaboutscala.com/tutorials/chapter-5-traits/scala-traits-depedency-injection/)
- [6: Learn How To Use Traits For Dependency Injection Part 2 - Avoid Cake Pattern](http://allaboutscala.com/tutorials/chapter-5-traits/scala-traits-depedency-injection-avoid-cake-pattern/)
- [7: Traits, Companion Object, Factory Pattern](http://allaboutscala.com/tutorials/chapter-5-traits/scala-traits-companion-object-factory-pattern/)
### Chapter 6: Immutable Collection
- [1: Introduction](http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/)
- [2: Learn How To Use Scala's Immutable List](http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-list/)
- [3: Learn How To Use Scala's Immutable ListSet](http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-listset/)
- [4: Learn How To Use Scala's Immutable ListMap](http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-listmap/)
- [5: Learn How To Use Scala's Immutable Map](http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-map/)
- [6: Learn How To Use Scala's Immutable HashMap](http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-hashmap/)
- [7: Learn How To Use Scala's Immutable TreeMap](http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-treemap/)
- [8: Learn How To Use Scala's Immutable Queue](http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-queue/)
- [9: Learn How To Use Scala's Immutable Sequence](http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-sequence/)
- [10: Learn How To Use Scala's Immutable Set](http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-set/)
- [11: Learn How To Use Scala's Immutable HashSet](http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-hashset/)
- [12: Learn How To Use Scala's Immutable TreeSet](http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-treeset/)
- [13: Learn How To Use Scala’s Immutable SortedSet](http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-sortedset/)
- [14: Learn How To Use Scala's Immutable BitSet](http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-bitset/)
- [15: Learn How To Use Scala's Immutable Stack](http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-stack/)
- [16: Learn How To Use Scala's Immutable Stream](http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-stream/)
- [17: Learn How To Use Scala's Immutable Vector](http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-vector/)
### Chapter 7: Mutable Collection
- [1: Introduction](http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/)
- [2: Learn How To Use Scala's Mutable Array](http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-array/)
- [3: Learn How To Use Scala's Mutable ArrayBuffer](http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-arraybuffer/)
- [4: Learn How To Use Scala's Mutable ArrayStack](http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-arraystack/)
- [5: Learn How To Use Scala's Mutable ListBuffer](http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-listbuffer/)
- [6: Learn How To Use Scala's Mutable Map](http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-map/)
- [7: Learn How To Use Scala's Mutable HashMap](http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-hashmap/)
- [8:Learn How To Use Scala's Mutable ListMap](http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-listmap/)
- [9: Learn How To Use Scala's Mutable LinkedHashMap](http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-linkedhashmap/)
- [10: Learn How To Use Scala's Mutable Queue](http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-queue/)
- [11: Learn How To Use Scala's Mutable PriorityQueue](http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-priorityqueue/)
- [12: Learn How To Use Scala's Mutable Set](http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-set/)
- [13: Learn How To Use Scala's Mutable HashSet](http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-hashset/)
- [14: Learn How To Use Scala's Mutable SortedSet](http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-sortedset/)
- [15: Learn How To Use Scala's Mutable TreeSet](http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-treeset/)
- [16: Learn How To Use Scala's Mutable LinkedHashSet](http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-linkedhashset/)
- [17: Learn How To Use Scala's Mutable BitSet](http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-bitset/)
### Chapter 8: Collection Functions
- [1: Introduction](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/)
- [2: Learn How To Use Aggregate Function](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-aggregate-function/)
- [3: Learn How To Use Collect Function](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-collect-function/)
- [4: Learn How To Use Diff Function](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-diff-function/)
- [5: Learn How To Use Drop Function](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-drop-function/)
- [6: Learn How To Use DropWhile Function](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-dropwhile-function/)
- [7: Learn How To Use Exists Function](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-exists-function/)
- [8: Learn How To Use Filter And FilterNot Functions](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-filter-filternot-function/)
- [9: Learn How To Use Find Function](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-find-function/)
- [10: Learn How To Use FlatMap Function](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-flatmap-function/)
- [11: Learn How To Use Flatten Function](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-flatten-function-example/)
- [12: Learn How To Use Fold Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-fold-example/)
- [13: Learn How To Use FoldLeft Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-foldleft-example/)
- [14: Learn How To Use FoldRight Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-foldright-example/)
- [15: Learn How To Use Foreach Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-foreach-example/)
- [16: Learn How To Use GroupBy Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-groupby-example/)
- [17: Learn How To Use Head Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-head-example/)
- [18: Learn How To Use IsEmpty Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-isempty-example/)
- [19: Learn How To Use Intersect Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-intersect-example/)
- [20: Learn How To Use Last Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-last-example/)
- [21: Learn How To Use Map Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-map-example/)
- [22: Learn How To Use Max Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-max-example/)
- [23: Learn How To Use MaxBy Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-maxby-example/)
- [24: Learn How To Use Min Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-min-example/)
- [25: Learn How To Use MinBy Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-minby-example/)
- [26: Learn How To Use MkString Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-mkstring-example/)
- [27: Learn How To Use NonEmpty Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-nonempty-example/)
- [28: Learn How To Use Par Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-par-example/)
- [29: Learn How To Use Partition Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-partition-example/)
- [30: Learn How To Use Reduce Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reduce-example/)
- [31: Learn How To Use ReduceLeft Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reduceleft-example/)
- [32: Learn How To Use ReduceRight Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reduceright-example/)
- [33: Learn How To Use Reverse Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reverse-example/)
- [34: Learn How To Use ReverseIterator Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reverseiterator-example/)
- [35: Learn How To Use Scan Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-scan-example/)
- [36: Learn How To Use ScanLeft Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-scanleft-example/)
- [37: Learn How To Use ScanRight Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-scanright-example/)
- [38: Learn How To Use Size Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-size-example/)
- [39: Learn How To Use Slice Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-slice-example/)
- [40: Learn How To Use SortBy Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-sortby-example/)
- [41: Learn How To Use Sorted Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-sorted-example/)
- [42: Learn How To Use SortWith Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-sortwith-example/)
- [43: Learn How To Use Tail Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-tail-example/)
- [44: Learn How To Use Take Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-take-example/)
- [45: Learn How To Use TakeRight Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-takeright-example/)
- [46: Learn How To Use TakeWhile Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-takewhile-example/)
- [47: Learn How To Use Transpose Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-transpose-example/)
- [48: Learn How To Use Union Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-union-example/)
- [49: Learn How To Use Unzip Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-unzip-example/)
- [50: Learn How To Use Unzip3 Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-unzip3-example/)
- [51: Learn How To Use View Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-view-example/)
- [52: Learn How To Use WithFilter Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-withfilter-example/)
- [53: Learn How To Use Zip Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-zip-example/)
- [54: Learn How To Use ZipWithIndex Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-zipwithindex-example/)
### Chapter 9: Futures
- [1: Method with future as return type](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#method-future-return-type)
- [2: Non blocking future result](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#non-blocking-future-result)
- [3: Chain futures using flatMap](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#chain-futures-using-flatmap)
- [4: Chain futures using for comprehension](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#chain-futures-using-for-comprehension)
- [5: Future option with for comprehension](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-option-with-for-comprehension)
- [6: Future option with map](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-option-with-map)
- [7: Composing futures](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#composing-futures)
- [8: Future sequence](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-sequence)
- [9: Future traverse](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-traverse)
- [10: Future foldLeft](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-foldLeft)
- [11: Future reduceLeft](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-reduceLeft)
- [12: Future firstCompletedOf](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-firstCompletedOf)
- [13: Future zip](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-zip)
- [14: Future zipWith](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-zipWith)
- [15: Future andThen](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-andThen)
- [16: Future configure threadpool](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-configure-threadpool)
- [17: Future recover](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-recover)
- [18: Future recoverWith](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-recoverWith)
- [19: Future fallbackTo](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-fallbackTo)
- [20: Future promise](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-promise)
### Chapter 10: Cheatsheet and Scala Test
### ScalaTest
- [Introduction](http://allaboutscala.com/scala-cheatsheet/#scalatest-introduction)
- [Add ScalaTest as dependency to build.sbt](http://allaboutscala.com/scala-cheatsheet/#add-scalatest-dependency-build.sbt)
- [Create a test class using FlatSpec and Matchers](http://allaboutscala.com/scala-cheatsheet/#test-class-flatspec-matchers)
- [Equality Test](http://allaboutscala.com/scala-cheatsheet/#scalatest-equality)
- [Length Test](http://allaboutscala.com/scala-cheatsheet/#scalatest-length)
- [Boolean Test](http://allaboutscala.com/scala-cheatsheet/#scalatest-boolean)
- [Collection Test](http://allaboutscala.com/scala-cheatsheet/#scalatest-collection)
- [Type Test](http://allaboutscala.com/scala-cheatsheet/#scalatest-type)
- [Exception Test](http://allaboutscala.com/scala-cheatsheet/#scalatest-exception)
- [Private Method Test](http://allaboutscala.com/scala-cheatsheet/#scalatest-private-method)
- [Future Method Test](http://allaboutscala.com/scala-cheatsheet/#scalatest-future)
### Collection
- [Convert Java collection](http://allaboutscala.com/scala-cheatsheet/#convert-java-collection-to-scala)
### General
- [Add line break](http://allaboutscala.com/scala-cheatsheet/#line-separator)
- [Convert multi-line string into single line](http://allaboutscala.com/scala-cheatsheet/#multi-line-to-single-line)
- [Check value of an Option](http://allaboutscala.com/scala-cheatsheet/#check-option-value)
- [Read file content as a String](http://allaboutscala.com/scala-cheatsheet/#read-file)
- [Create enum using sealed trait](http://allaboutscala.com/scala-cheatsheet/#create-enum-sealed-trait)
- [Int division and return float](http://allaboutscala.com/scala-cheatsheet/#int-division-scala)
### Futures
- [Cannot find an implicit ExecutionContext](http://allaboutscala.com/scala-cheatsheet/#implicit-executioncontext)
### Chapter 11: Learn SBT
#### Install SBT
- [Install SBT on Windows](http://allaboutscala.com/scala-frameworks/sbt/#install-sb-windows)
- [Install SBT on Mac](http://allaboutscala.com/scala-frameworks/sbt/#install-sbt-mac)
#### sbt run
- [Run a Scala main class](http://allaboutscala.com/scala-frameworks/sbt/#sbt-run-main-class)
#### sbt test
- [Run all tests](http://allaboutscala.com/scala-frameworks/sbt/#sbt-run-test)
- [Run only one specific test](http://allaboutscala.com/scala-frameworks/sbt/#sbt-run-specific-test)
- [Run all integration tests](http://allaboutscala.com/scala-frameworks/sbt/#sbt-run-it-test)
- [Run a specific integration test](http://allaboutscala.com/scala-frameworks/sbt/#sbt-run-specific-it-test)
- [Run one method in a test class](http://allaboutscala.com/scala-frameworks/sbt/#sbt-run-specific-test-and-test-method)
#### sbt debugging
- [Analyze stacktrace in IntelliJ](http://allaboutscala.com/scala-frameworks/sbt/#sbt-debug-stacktrace-intellij)
#### sbt resources
- [Show unmanaged classpaths](http://allaboutscala.com/scala-frameworks/sbt/#sbt-show-unmanaged-classpaths)
- [Show unmanaged resources](http://allaboutscala.com/scala-frameworks/sbt/#sbt-show-unmanaged-resource-directories)
### Chapter 12: Learn Apache Spark 2
### Chapter 12 - Part 1
#### Project Setup
- [StackOverflow dataset](http://allaboutscala.com/big-data/spark/#stackoverflow-dataset)
- [Add Apache Spark 2.0 SBT dependencies](http://allaboutscala.com/big-data/spark/#spark-sbt-dependencies)
- [Bootstrap a SparkSession](http://allaboutscala.com/big-data/spark/#bootstrap-sparksession)
#### DataFrame SQL Query
- [DataFrame Introduction](http://allaboutscala.com/big-data/spark/#dataframe-introduction)
- [Create a DataFrame from reading a CSV file](http://allaboutscala.com/big-data/spark/#create-dataframe-read-csv)
- [DataFrame schema](http://allaboutscala.com/big-data/spark/#print-dataframe-schema)
- [Select columns from a dataframe](http://allaboutscala.com/big-data/spark/#dataframe-select-columns)
- [Filter by column value of a dataframe](http://allaboutscala.com/big-data/spark/#filter-column-dataframe)
- [Count rows of a dataframe](http://allaboutscala.com/big-data/spark/#dataframe-count-rows)
- [SQL like query](http://allaboutscala.com/big-data/spark/#dataframe-sql-like-query)
- [Multiple filter chaining](http://allaboutscala.com/big-data/spark/#dataframe-multiple-filter-chains)
- [SQL IN clause](http://allaboutscala.com/big-data/spark/#dataframe-sql-in-clause)
- [SQL Group By](http://allaboutscala.com/big-data/spark/#dataframe-sql-group-by)
- [SQL Group By with filter](http://allaboutscala.com/big-data/spark/#dataframe-sql-group-by-count-filter)
- [SQL order by](http://allaboutscala.com/big-data/spark/#dataframe-order-by)
- [Cast columns to specific data type](http://allaboutscala.com/big-data/spark/#dataframe-cast-columns-data-type)
- [Operate on a filtered dataframe](http://allaboutscala.com/big-data/spark/#dataframe-operations)
- [DataFrame Join](http://allaboutscala.com/big-data/spark/#dataframe-join)
- [Join and select columns](http://allaboutscala.com/big-data/spark/#dataframe-join-select-columns)
- [Join on explicit columns](http://allaboutscala.com/big-data/spark/#dataframe-join-explicit-columns)
- [Inner Join](http://allaboutscala.com/big-data/spark/#dataframe-inner-join)
- [Left Outer Join](http://allaboutscala.com/big-data/spark/#dataframe-left-outer-join)
- [Right Outer Join](http://allaboutscala.com/big-data/spark/#dataframe-right-outer-join)
- [Distinct](http://allaboutscala.com/big-data/spark/#dataframe-distinct)
### Chatper 12 - Part 2
#### Spark SQL
- [Spark SQL Introduction](http://allaboutscala.com/big-data/spark/#spark-sql-introduction)
- [Register temp table from dataframe](http://allaboutscala.com/big-data/spark/#register-temp-table-from-dataframe)
- [List all tables in Spark's catalog](http://allaboutscala.com/big-data/spark/#list-tables-spark-catalog)
- [List catalog tables using Spark SQL](http://allaboutscala.com/big-data/spark/#list-catalog-tables-spark-sql)
- [Select columns](http://allaboutscala.com/big-data/spark/#spark-sql-select-columns)
- [Filter by column value](http://allaboutscala.com/big-data/spark/#spark-sql-filter-column-value)
- [Count number of rows](http://allaboutscala.com/big-data/spark/#spark-sql-count-rows)
- [SQL like](http://allaboutscala.com/big-data/spark/#spark-sql-like)
- [SQL where with and clause](http://allaboutscala.com/big-data/spark/#spark-sql-where-with-and-clause)
- [SQL IN clause](http://allaboutscala.com/big-data/spark/#spark-sql-in-clause)
- [SQL Group By](http://allaboutscala.com/big-data/spark/#spark-sql-group-by)
- [SQL Group By with having clause](http://allaboutscala.com/big-data/spark/#spark-sql-group-by-having-clause)
- [SQL Order by](http://allaboutscala.com/big-data/spark/#spark-sql-order-by)
- [Typed columns, filter and create temp table](http://allaboutscala.com/big-data/spark/#spark-sql-typed-column-filter-temp-table)
- [SQL Inner Join](http://allaboutscala.com/big-data/spark/#spark-sql-inner-join)
- [SQL Left Outer Join](http://allaboutscala.com/big-data/spark/#spark-sql-left-outer-join)
- [SQL Right Outer Join](http://allaboutscala.com/big-data/spark/#spark-sql-right-outer-join)
- [SQL Distinct](http://allaboutscala.com/big-data/spark/#spark-sql-distinct)
- [Register User Defined Function (UDF)](http://allaboutscala.com/big-data/spark/#spark-sql-udf)
### Chapter 12 - Part 3
#### DataFrame Statistics
- [DataFrame Statistics Introduction](http://allaboutscala.com/big-data/spark/#dataframe-statistics-introduction)
- [Create DataFrame from CSV](http://allaboutscala.com/big-data/spark/#create-dataframe-csv)
- [Average](http://allaboutscala.com/big-data/spark/#dataframe-statistics-average)
- [Maximum](http://allaboutscala.com/big-data/spark/#dataframe-statistics-max)
- [Minimum](http://allaboutscala.com/big-data/spark/#dataframe-statistics-minimum)
- [Mean](http://allaboutscala.com/big-data/spark/#dataframe-statistics-mean)
- [Sum](http://allaboutscala.com/big-data/spark/#dataframe-statistics-sum)
- [Group by query with statistics](http://allaboutscala.com/big-data/spark/#dataframe-statistics-group-by-query)
- [DataFrame Statistics using describe() method](http://allaboutscala.com/big-data/spark/#dataframe-statistics-describe-method)
- [Correlation](http://allaboutscala.com/big-data/spark/#dataframe-statistics-correlation)
- [Covariance](http://allaboutscala.com/big-data/spark/#dataframe-statistics-covariance)
- [Frequent Items](http://allaboutscala.com/big-data/spark/#dataframe-statistics-frequent-items)
- [Crosstab](http://allaboutscala.com/big-data/spark/#dataframe-statistics-crosstab)
- [Stratified sampling using sampleBy](http://allaboutscala.com/big-data/spark/#dataframe-statistics-sampleby)
- [Approximate Quantile](http://allaboutscala.com/big-data/spark/#dataframe-statistics-approxquantile)
- [Bloom Filter](http://allaboutscala.com/big-data/spark/#spark-dataframe-bloom-filter)
- [Count Min Sketch](http://allaboutscala.com/big-data/spark/#dataframe-statistics-count-min-sketch)
- [Sampling With Replacement](http://allaboutscala.com/big-data/spark/#dataframe-sampling-with-replacement)
### Chapter 12 - Part 4
#### DataFrame Operations
- [DataFrame Operations Introduction](http://allaboutscala.com/big-data/spark/#dataframe-operations-introduction)
- [Setup DataFrames](http://allaboutscala.com/big-data/spark/#dataframe-operations-setup)
- [Convert DataFrame row to Scala case class](http://allaboutscala.com/big-data/spark/#dataframe-convert-row-scala-case-class)
- [DataFrame row to Scala case class using map()](http://allaboutscala.com/big-data/spark/#dataframe-row-scala-case-class-map-method)
- [Create DataFrame from collection](http://allaboutscala.com/big-data/spark/#create-dataframe-from-collection)
- [DataFrame Union](http://allaboutscala.com/big-data/spark/#dataframe-union)
- [DataFrame Intersection](http://allaboutscala.com/big-data/spark/#dataframe-intersection)
- [Append column to DataFrame using withColumn()](http://allaboutscala.com/big-data/spark/#dataframe-append-column-withcolumn-method)
#### Spark Functions
- [Create DataFrame from Tuples](http://allaboutscala.com/big-data/spark/#create-dataframe-from-tuples)
- [Get DataFrame column names](http://allaboutscala.com/big-data/spark/#get-dataframe-column-names)
- [DataFrame column names and types](http://allaboutscala.com/big-data/spark/#dataframe-column-names-and-types)
- [Nested Json into DataFrame using explode method](http://allaboutscala.com/big-data/spark/#json-into-dataframe-using-explode-method)
- [Concatenate DataFrames using join() method](http://allaboutscala.com/big-data/spark/#concatenate-dataframes-using-join)
- [Search DataFrame column using array_contains() method](http://allaboutscala.com/big-data/spark/#search-dataframe-column-using-array-contains-method)
- [Check DataFrame column exists](http://allaboutscala.com/big-data/spark/#check-dataframe-column-exists)
- [Split DataFrame Array column](http://allaboutscala.com/big-data/spark/#split-dataframe-array-column)
- [Rename DataFrame column](http://allaboutscala.com/big-data/spark/#rename-dataframe-column)
- [Create DataFrame constant column](http://allaboutscala.com/big-data/spark/#create-dataframe-constant-column)
- [DataFrame new column with User Defined Function (UDF](http://allaboutscala.com/big-data/spark/#dataframe-new-column-with-udf)
- [DataFrame first row](http://allaboutscala.com/big-data/spark/#dataframe-first-row)
- [Format DataFrame column](http://allaboutscala.com/big-data/spark/#format-dataframe-column)
- [DataFrame column hashing](http://allaboutscala.com/big-data/spark/#dataframe-column-hashing)
- [DataFrame String functions](http://allaboutscala.com/big-data/spark/#dataframe-string-functions)
- [DataFrame drop null](http://allaboutscala.com/big-data/spark/#dataframe-drop-null)
### Chapter 13 - Learn Akka
#### Introduction
- [What is Akka](http://allaboutscala.com/scala-frameworks/akka/#what-is-akka)
- [Project setup build.sbt](http://allaboutscala.com/scala-frameworks/akka/#project-setup-build-sbt)
#### Akka Actors
- [Actor System Introduction](http://allaboutscala.com/scala-frameworks/akka/#actor-system-introduction)
- [Tell Pattern](http://allaboutscala.com/scala-frameworks/akka/#tell-pattern)
- [Ask Pattern](http://allaboutscala.com/scala-frameworks/akka/#ask-pattern)
- [Ask Pattern mapTo](http://allaboutscala.com/scala-frameworks/akka/#ask-pattern-mapto)
- [Ask Pattern pipeTo](http://allaboutscala.com/scala-frameworks/akka/#ask-pattern-pipeto)
- [Actor Hierarchy](http://allaboutscala.com/scala-frameworks/akka/#actor-hierarchy)
- [Actor Lookup](http://allaboutscala.com/scala-frameworks/akka/#actor-lookup)
- [Child Actors](http://allaboutscala.com/scala-frameworks/akka/#child-actors)
- [Actor Lifecycle](http://allaboutscala.com/scala-frameworks/akka/#actor-lifecycle)
- [Actor PoisonPill](http://allaboutscala.com/scala-frameworks/akka/#actor-poisonpill)
- [Error Kernel Supervision](http://allaboutscala.com/scala-frameworks/akka/#error-kernel-supervision)
#### Akka Routers
- [RoundRobinPool](http://allaboutscala.com/scala-frameworks/akka/#roundrobinpool-router)
- [ScatterGatherFirstCompletedPool](http://allaboutscala.com/scala-frameworks/akka/#scattergatherfirstcompletedpool-router)
- [TailChoppingPool](http://allaboutscala.com/scala-frameworks/akka/#tailchoppingpool-router)
- [BroadcastPool](http://allaboutscala.com/scala-frameworks/akka/#broadcastpool-router)
#### Akka Dispatchers
- [Akka Default Dispatcher](http://allaboutscala.com/scala-frameworks/akka/#akka-default-dispatcher)
- [Akka Lookup Dispatcher](http://allaboutscala.com/scala-frameworks/akka/#akka-lookup-dispatcher)
- [Fixed Thread Pool Dispatcher](http://allaboutscala.com/scala-frameworks/akka/#fixed-thread-pool-dispatcher)
- [Resizable Thread Pool Dispatcher](http://allaboutscala.com/scala-frameworks/akka/#resizable-thread-pool)
- [Pinned Thread Pool Dispatcher](http://allaboutscala.com/scala-frameworks/akka/#pinned-thread-pool-dispatcher)
#### Akka FSM
- [Actor FSM become()](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-become)
- [Actor FSM unbecome()](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-unbecome)
- [Actor FSM protocol](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-protocol)
- [Actor LoggingFSM](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-loggingfsm)
- [Actor LoggingFSM Part Two](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-loggingfsm-part-two)
- [Actor LoggingFSM Part Three](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-loggingfsm-part-three)
- [Actor LoggingFSM Part Four](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-loggingfsm-part-four)
- [Actor LoggingFSM Part Five](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-loggingfsm-part-five)
- [Actor LoggingFSM Part Six](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-loggingfsm-part-six)
- [Actor FSM Scheduler](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-scheduler)
#### Akka TestKit
- [Testing Actor FSM](http://allaboutscala.com/scala-frameworks/akka/#akka-testkit-test-actor-fsm)
- [Testing Actor](http://allaboutscala.com/scala-frameworks/akka/#akka-testkit-test-actor)
- [Testing Akka HTTP POST](http://allaboutscala.com/scala-frameworks/akka/#akka-testkit-http-post)
- [Testing Query Parameter](http://allaboutscala.com/scala-frameworks/akka/#akka-testkit-query-parameter)
- [Testing Required Query Parameter](http://allaboutscala.com/scala-frameworks/akka/#akka-testkit-required-query-parameter)
- [Testing Optional Query Parameter](http://allaboutscala.com/scala-frameworks/akka/#akka-testkit-optional-query-parameter)
- [Testing Typed Query Parameter](http://allaboutscala.com/scala-frameworks/akka/#akka-testkit-typed-query-parameter)
- [Testing CSV Query Parameter](http://allaboutscala.com/scala-frameworks/akka/#akka-testkit-csv-query-parameter)
#### Akka HTTP
- [Akka HTTP project setup build.sbt](http://allaboutscala.com/scala-frameworks/akka/#akka-http-project-setup-build-sbt)
- [Start Akka HTTP Server](http://allaboutscala.com/scala-frameworks/akka/#akka-http-start-server)
- [HTTP GET plain text](http://allaboutscala.com/scala-frameworks/akka/#akka-http-get-plain-text)
- [HTTP GET JSON response](http://allaboutscala.com/scala-frameworks/akka/#akka-http-get-json-response)
- [JSON encoding](http://allaboutscala.com/scala-frameworks/akka/#akka-http-json-encoding)
- [JSON pretty print](http://allaboutscala.com/scala-frameworks/akka/#akka-http-json-pretty-print)
- [HTTP POST JSON payload](http://allaboutscala.com/scala-frameworks/akka/#akka-http-post-json)
- [Could not find implicit value](http://allaboutscala.com/scala-frameworks/akka/#akka-http-could-not-find-implicit-value)
- [HTTP DELETE restriction](http://allaboutscala.com/scala-frameworks/akka/#akka-http-delete-method-restriction)
- [Future onSuccess](http://allaboutscala.com/scala-frameworks/akka/#akka-http-future-onsuccess)
- [Future onComplete](http://allaboutscala.com/scala-frameworks/akka/#akka-http-future-oncomplete)
- [Complete with an HttpResponse](http://allaboutscala.com/scala-frameworks/akka/#akka-http-complete-httpresponse)
- [Try failure using an HttpResponse](http://allaboutscala.com/scala-frameworks/akka/#akka-http-try-failure-httpresponse)
- [Global rejection handler](http://allaboutscala.com/scala-frameworks/akka/#akka-http-global-rejection-handler)
- [Global exception handler](http://allaboutscala.com/scala-frameworks/akka/#akka-http-global-exception-handler)
- [Load HTML from resources](http://allaboutscala.com/scala-frameworks/akka/#akka-http-load-html-resource)
- [RESTful URLs with segment](http://allaboutscala.com/scala-frameworks/akka/#akka-http-rest-url-segment)
- [RESTful URLS with regex](http://allaboutscala.com/scala-frameworks/akka/#akka-http-rest-url-regex)
- [RESTful URLS with multiple segments](http://allaboutscala.com/scala-frameworks/akka/#akka-http-multiple-segments)
- [Query parameter](http://allaboutscala.com/scala-frameworks/akka/#akka-http-query-parameter)
- [Optional query parameter](http://allaboutscala.com/scala-frameworks/akka/#akka-http-optional-query-parameter)
- [Typed query parameters](http://allaboutscala.com/scala-frameworks/akka/#akka-http-typed-query-parameters)
- [CSV query parameter](http://allaboutscala.com/scala-frameworks/akka/#akka-http-csv-query-parameter)
- [Query parameter to case class](http://allaboutscala.com/scala-frameworks/akka/#akka-http-query-parameter-to-case-class)
- [HTTP request headers](http://allaboutscala.com/scala-frameworks/akka/#akka-http-request-headers)
- [HTTP client GET](http://allaboutscala.com/scala-frameworks/akka/#akka-http-client-get)
- [Unmarshal HttpResponse to case class](http://allaboutscala.com/scala-frameworks/akka/#akka-http-unmarshal-case-class)
- [HTTP client POST JSON](http://allaboutscala.com/scala-frameworks/akka/#akka-http-client-post-json)
### Chapter 14 - Learn Cassandra
#### Introduction
- [What is Apache Cassandra](http://allaboutscala.com/big-data/cassandra/#introduction)
- [Install Apache Cassandra](http://allaboutscala.com/big-data/cassandra/#install-apache-cassandra)
- [Using nodetool](http://allaboutscala.com/big-data/cassandra/#using-nodetool)
- [cassandra.yaml](http://allaboutscala.com/big-data/cassandra/#cassandra.yaml)
- [cqlsh](http://allaboutscala.com/big-data/cassandra/#cqlsh)
- [Load CQL statements from file](http://allaboutscala.com/big-data/cassandra/#load-cql-statements-from-file)
- [Partition keys](http://allaboutscala.com/big-data/cassandra/#partition-keys)
- [Clustering keys](http://allaboutscala.com/big-data/cassandra/#clustering-keys)
- [Cassandra CQL is not SQL!](http://allaboutscala.com/big-data/cassandra/#cassandra-cql-is-not-sql)
- [Multiple clustering keys](http://allaboutscala.com/big-data/cassandra/#multiple-clustering-keys)
- [Clustering keys restrictions](http://allaboutscala.com/big-data/cassandra/#clustering-keys-restrictions)
- [Secondary index](http://allaboutscala.com/big-data/cassandra/#secondary-index)
- [Create materialized view](http://allaboutscala.com/#chapter-14-learn-apache-cassandra)
### Chapter 15 - Scala Exercises
- [Scala Exercises](https://github.com/nadimbahadoor/scala-exercises)
- [Scala Exercises With Solutions](http://allaboutscala.com/tutorials/scala-exercises-solutions/)
### Chapter 16 - Data Science
- [Spark NLP Covid-19 versus The Avengers](http://allaboutscala.com/data-science/spark-nlp-covid-19/)
Stay in touch via [LinkedIn](https://www.linkedin.com/in/nadimbahadoor/), [Facebook](http://www.facebook.com/allaboutscala) and [Twitter](https://twitter.com/NadimBahadoor) for upcoming tutorials!
## Contact
Nadim Bahadoor at http://allaboutscala.com/contact/
## License
Apache 2.0 License - see the LICENSE.TXT file
================================================
FILE: source-code/allaboutscala/.gitignore
================================================
*.class
*.log
# sbt specific
.cache
.history
.lib/
dist/*
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project/
# Scala-IDE specific
.scala_dependencies
.worksheet
.idea
================================================
FILE: source-code/allaboutscala/build.sbt
================================================
name := "allaboutscala"
version := "1.0"
scalaVersion := "2.12.4"
val scalaLogging = "com.typesafe.scala-logging" %% "scala-logging" % "3.8.0"
val logback = "ch.qos.logback" % "logback-classic" % "1.1.7"
val jodaTime = "joda-time" % "joda-time" % "2.9.3"
val jodaConvert = "org.joda" % "joda-convert" % "1.8"
libraryDependencies ++= Seq (
scalaLogging,
logback,
jodaTime,
jodaConvert
)
================================================
FILE: source-code/allaboutscala/project/build.properties
================================================
sbt.version = 0.13.8
================================================
FILE: source-code/allaboutscala/project/plugins.sbt
================================================
logLevel := Level.Warn
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Aggregate_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Aggregate Function
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-aggregate-function/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Aggregate_Tutorial extends App {
println("Step 1: How to initialize a Set of type String to represent Donut elements")
val donutBasket1: Set[String] = Set("Plain Donut", "Strawberry Donut")
println(s"Elements of donutBasket1 = $donutBasket1")
println("\nStep 2: How to define an accumulator function to calculate the total length of the String elements")
val donutLengthAccumulator: (Int, String) => Int = (accumulator, donutName) => accumulator + donutName.length
println("\nStep 3: How to call aggregate function with the accumulator function from Step 2")
val totalLength = donutBasket1.aggregate(0)(donutLengthAccumulator, _ + _)
println(s"Total length of elements in donutBasket1 = $totalLength")
println("\nStep 4: How to initialize a Set of Tuple3 elements to represent Donut name, price and quantity")
val donutBasket2: Set[(String, Double, Int)] = Set(("Plain Donut", 1.50, 10), ("Strawberry Donut", 2.0, 10))
println(s"Elements of donutBasket2 = $donutBasket2")
println("\nStep 5: How to define an accumulator function to calculate the total cost of Donuts")
val totalCostAccumulator: (Double, Double, Int) => Double = (accumulator, price, quantity) => accumulator + (price * quantity)
println("\nStep 6: How to call aggregate function with accumulator function from Step 5")
val totalCost = donutBasket2.aggregate(0.0)((accumulator: Double, tuple: (String, Double, Int)) => totalCostAccumulator(accumulator, tuple._2, tuple._3), _ + _)
println(s"Total cost of donuts in donutBasket2 = $totalCost")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Collect_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Collect Function
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-collect-function/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Collect_Tutorial extends App {
println("Step 1: How to initialize a Sequence which contains donut names and prices")
val donutNamesandPrices: Seq[Any] = Seq("Plain Donut", 1.5, "Strawberry Donut", 2.0, "Glazed Donut", 2.5)
println(s"Elements of donutNamesAndPrices = $donutNamesandPrices")
println("\nStep 2: How to use collect function to cherry pick all the donut names")
val donutNames: Seq[String] = donutNamesandPrices.collect{ case name: String => name }
println(s"Elements of donutNames = $donutNames")
println("\nStep 3: How to use collect function to cherry pick all the donut prices")
val donutPrices: Seq[Double] = donutNamesandPrices.collect{ case price: Double => price }
println(s"Elements of donutPrices = $donutPrices")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Diff_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Diff Function
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-diff-function/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Diff_Tutorial extends App {
println("Step 1: How to initialize a Set containing 3 donuts")
val donutBasket1: Set[String] = Set("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donutBasket1 = $donutBasket1")
println("\nStep 2: How to initialize a Set containing 2 donuts")
val donutBasket2: Set[String] = Set("Glazed Donut", "Vanilla Donut")
println(s"Elements of donutBasket2 = $donutBasket2")
println("\nStep 3: How to find the difference between two Sets using the diff function")
val diffDonutBasket1From2: Set[String] = donutBasket1 diff donutBasket2
println(s"Elements of diffDonutBasket1From2 = $diffDonutBasket1From2")
println("\nStep 4: How to find the difference between two Sets using the diff function")
val diffDonutBasket2From1: Set[String] = donutBasket2 diff donutBasket1
println(s"Elements of diff DonutBasket2From1 = $diffDonutBasket2From1")
println("\nStep 5: How to find the difference between two Sets using the --")
println(s"Difference between donutBasket1 and donutBasket2 = ${donutBasket1 -- donutBasket2}")
println(s"Difference between donutBasket2 and donutBasket1 = ${donutBasket2 -- donutBasket1}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/DropWhile_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use DropWhile Function
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-dropwhile-function/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object DropWhile_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to drop elements from the sequence using the dropWhile function")
println(s"Drop donut elements whose name starts with letter P = ${donuts.dropWhile(_.charAt(0) == 'P')}")
println("\nStep 3: How to declare a predicate function to be passed-through to the dropWhile function")
val dropElementsPredicate: (String) => Boolean = (donutName) => donutName.charAt(0) == 'P'
println(s"Value function dropElementsPredicate = $dropElementsPredicate")
println("\nStep 4: How to drop elements using the predicate function from Step 3")
println(s"Drop elements using function from Step 3 = ${donuts.dropWhile(dropElementsPredicate)}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Drop_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Drop Function
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-drop-function/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Drop_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to drop the first element using drop function")
println(s"Drop the first element in the sequence = ${donuts.drop(1)}")
println("\nStep 3: How to drop the first two elements using the drop function")
println(s"Drop the first and second elements in the sequence = ${donuts.drop(2)}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Exists_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Exists Function
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-exists-function/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Exists_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to check if a particular element exists in the sequence using the exists function")
val doesPlainDonutExists: Boolean = donuts.exists(donutName => donutName == "Plain Donut")
println(s"Does Plain Donut exists = $doesPlainDonutExists")
println("\nStep 3: How to declare a predicate value function for the exists function")
val plainDonutPredicate: (String) => Boolean = (donutName) => donutName == "Plain Donut"
println(s"Value function plainDonutPredicate = $plainDonutPredicate")
println("\nStep 4: How to find element Plain Donut using the exists function and passing through the predicate function from Step 3")
println(s"Does Plain Donut exists = ${donuts.exists(plainDonutPredicate)}")
println("\nStep 5: How to declare a predicate def function for the exists function")
def plainDonutPredicateFunction(donutName: String): Boolean = donutName == "Plain Donut"
println("\nStep 6: How to find element Plain Donut using the exists function and passing through the predicate function from Step 5")
println(s"Does plain Donut exists = ${donuts.exists(plainDonutPredicateFunction(_))}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/FilterFilterNot_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Filter And FilterNot Function
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-filter-filternot-function/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object FilterFilterNot_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut", "Vanilla Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to keep only Plain and Glazed Donuts using the filter method")
val sequenceWithPlainAndGlazedDonut = donuts.filter { donutName =>
donutName.contains("Plain") || donutName.contains("Glazed")
}
println(s"Sequence with Plain and Glazed donuts only = $sequenceWithPlainAndGlazedDonut")
println("\nStep 3: How to filter out element Vanilla Donut using the filterNot function")
val sequenceWithoutVanillaDonut = donuts.filterNot(donutName => donutName == "Vanilla Donut" )
println(s"Sequence without vanilla donut = $sequenceWithoutVanillaDonut")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Find_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Find Function
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-find-function/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Find_Tutorial extends App {
println("Step 1: Initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to find a particular element in the sequence using the find function")
val plainDonut: Option[String] = donuts.find(donutName => donutName == "Plain Donut")
println(s"Find Plain Donut = ${plainDonut.get}")
println("\nStep 3: How to find element Vanilla Donut which does not exists in the sequence using the find function")
// val vanillaDonut: String = donuts.find(_ == "Vanilla Donut").get
// println(s"Find Vanilla Donuts = $vanillaDonut")
// NOTE: we get an exception Exception in thread "main" java.util.NoSuchElementException: None.get
println("\nStep 4: How to find element Vanilla Donut using the find function and getOrElse")
val vanillaDonut2: String = donuts.find(_ == "Vanilla Donut").getOrElse("Vanilla Donut was not found!")
println(s"Find Vanilla Donuts = $vanillaDonut2")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/FlatMap_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use FlatMap Function
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-flatmap-function/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object FlatMap_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts1: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts1 = $donuts1")
println("\nStep 2: How to initialize another Sequence of donuts")
val donuts2: Seq[String] = Seq("Vanilla Donut", "Glazed Donut")
println(s"Elements of donuts2 = $donuts2")
println("\nStep 3: How to create a List of donuts initialized using the two Sequences from Step 1 and Step 2")
val listDonuts: List[Seq[String]] = List(donuts1, donuts2)
println(s"Elements of listDonuts = $listDonuts")
// NOTE: we have a List(List(Plain Donut, Strawberry Donut, Glazed Donut), List(Vanilla Donut, Glazed Donut))
println("\nStep 4: How to return a single list of donut using the flatMap function")
val listDonutsFromFlatMap: List[String] = listDonuts.flatMap(seq => seq)
println(s"Elements of listDonutsFromFlatMap as a flatMap as a single list = $listDonutsFromFlatMap")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Flatten_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Flatten Function
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-flatten-function-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Flatten_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts1: Seq[String] = Seq("Plain", "Strawberry", "Glazed")
println(s"Elements of donuts1 = $donuts1")
println("\nStep 2: How to initialize another Sequence of donuts")
val donuts2: Seq[String] = Seq("Vanilla", "Glazed")
println(s"Elements of donuts2 = $donuts2")
println("\nStep 3: How to create a List of donuts initialized using the two Sequences from Step 1 and Step 2")
val listDonuts: List[Seq[String]] = List(donuts1, donuts2)
println(s"Elements of listDonuts = $listDonuts")
println("\nStep 4: How to return a single list of donut using the flatten function")
val listDonutsFromFlatten: List[String] = listDonuts.flatten
println(s"Elements of listDonutsFromFlatten = $listDonutsFromFlatten")
println("\nStep 5: How to append the word Donut to each element of listDonuts using flatten and map functions")
val listDonutsFromFlatten2: List[String] = listDonuts.flatten.map(_ + " Donut")
println(s"Elements of listDonutsFromFlatten2 = $listDonutsFromFlatten2")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/FoldLeft_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use FoldLeft Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-foldleft-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object FoldLeft_Tutorial extends App {
println("Step 1: How to initialize a sequence of donut prices")
val prices: Seq[Double] = Seq(1.5, 2.0, 2.5)
println(s"Donut prices = $prices")
println("\nStep 2: How to sum all the donut prices using foldLeft function")
val sum = prices.foldLeft(0.0)(_ + _)
println(s"Sum = $sum")
println("\nStep 3: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain", "Strawberry", "Glazed")
println(s"Elements of donuts1 = $donuts")
println("\nStep 4: How to create a String of all donuts using foldLeft function")
println(s"All donuts = ${donuts.foldLeft("")((a, b) => a + b + " Donut ")}")
println("\nStep 5: How to declare a value function to create the donut string")
val concatDonuts: (String, String) => String = (a, b) => a + b + " Donut "
println(s"Value function concatDonuts = $concatDonuts")
println("\nStep 6: How to create a String of all donuts using value function from Step 5 and fold function")
println(s"All donuts = ${donuts.foldLeft("")(concatDonuts)}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/FoldRight_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use FoldRight Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-foldright-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object FoldRight_Tutorial extends App {
println("Step 1: How to initialize a sequence of donut prices")
val prices: Seq[Double] = Seq(1.5, 2.0, 2.5)
println(s"Donut prices = $prices")
println("\nStep 2: How to sum all the donut prices using foldRight function")
val sum = prices.foldRight(0.0)(_ + _)
println(s"Sum = $sum")
println("\nStep 3: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain", "Strawberry", "Glazed")
println(s"Elements of donuts1 = $donuts")
println("\nStep 4: How to create a String of all donuts using foldRight function")
println(s"All donuts = ${donuts.foldRight("")((a, b) => a + " Donut " + b)}")
println("\nStep 5: How to declare a value function to create the donut string")
val concatDonuts: (String, String) => String = (a, b) => a + " Donut " + b
println(s"Value function concatDonuts = $concatDonuts")
println("\nStep 6: How to create a String of all donuts using value function from Step 5 and foldRight function")
println(s"All donuts = ${donuts.foldRight("")(concatDonuts)}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Fold_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Fold Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-fold-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Fold_Tutorial extends App {
println("Step 1: How to initialize a sequence of donut prices")
val prices: Seq[Double] = Seq(1.5, 2.0, 2.5)
println(s"Donut prices = $prices")
println("\nStep 2: How to sum all the donut prices using fold function")
val sum = prices.fold(0.0)(_ + _)
println(s"Sum = $sum")
println("\nStep 3: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain", "Strawberry", "Glazed")
println(s"Elements of donuts1 = $donuts")
println("\nStep 4: How to create a String of all donuts using fold function")
println(s"All donuts = ${donuts.fold("")((acc, s) => acc + s + " Donut ")}")
println("\nStep 5: How to declare a value function to create the donut string")
val concatDonuts: (String, String) => String = (s1, s2) => s1 + s2 + " Donut "
println(s"Value function concatDonuts = $concatDonuts")
println("\nStep 6: How to create a String of all donuts using value function from Step 5 and fold function")
println(s"All donuts = ${donuts.fold("")(concatDonuts)}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Foreach_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Foreach Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-foreach-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Foreach_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to loop through all the elements in the sequence using the foreach function")
donuts.foreach(println(_))
println("\nStep 3: How to loop through and access all the elements in the sequence using the foreach function")
donuts.foreach(donutName => println(s"donutName = $donutName"))
println("\nStep 4: How to declare a value function to format a donut names into upper case format")
val uppercase: (String) => String = (s) => {
val upper = s.toUpperCase
println(upper)
upper
}
println(s"Value function formatting donut names to uppercase = $uppercase")
println("\nStep 5: How to format all donuts to uppercase using value function from Step 4")
donuts.foreach(uppercase)
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/GroupBy_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use GroupBy Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-groupby-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object GroupBy_Tutorial extends App {
println("\nStep 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to group elements in a sequence using the groupBy function")
val donutsGroup: Map[Char, Seq[String]] = donuts.groupBy(_.charAt(0))
println(s"Group elements in the donut sequence by the first letter of the donut name = $donutsGroup")
println("\nStep 3: How to create a case class to represent Donut objects")
case class Donut(name: String, price: Double)
println("\nStep 4: How to create a Sequence of type Donut")
val donuts2: Seq[Donut] = Seq(Donut("Plain Donut", 1.5), Donut("Strawberry Donut", 2.0), Donut("Glazed Donut", 2.5))
println(s"Elements of donuts2 = $donuts2")
println(s"\nStep 5: How to group case classes donut objects by the name property")
val donutsGroup2: Map[String, Seq[Donut]] = donuts2.groupBy(_.name)
println(s"Group element in the sequence of type Donut grouped by the donut name = $donutsGroup2")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Head_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Head Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-head-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Head_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to access the first element of the donut sequence")
println(s"First element of donut sequence = ${donuts(0)}")
println("\nStep 3: How to access the first element of the donut sequence using the head method")
println(s"First element of donut sequence using head method = ${donuts.head}")
println("\nStep 4: How to create an empty sequence")
val donuts2: Seq[String] = Seq.empty[String]
println(s"Elements of donuts2 = $donuts2")
println("\nStep 5: How to access the first element of the donut sequence using the headOption function")
println(s"First element of empty sequence = ${donuts2.headOption.getOrElse("No donut was found!")}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Intersect_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Intersect Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-intersect-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Intersect_Tutorial extends App {
println("Step 1: How to initialize a Set of donuts")
val donuts1: Set[String] = Set("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts1 = $donuts1")
println("\nStep 2: How to initialize another Set of donuts")
val donuts2: Set[String] = Set("Plain Donut", "Chocolate Donut", "Vanilla Donut")
println(s"Elements of donuts2 = $donuts2")
println("\nStep 3: How to find the common elements between two Sets using intersect function")
println(s"Common elements between donuts1 and donuts2 = ${donuts1 intersect donuts2}")
println(s"Common elements between donuts2 and donuts1 = ${donuts2 intersect donuts1}")
println("\nStep 4: How to find the common elements between two Sets using & function")
println(s"Common elements between donuts1 and donuts2 = ${donuts1 & donuts2}")
println(s"Common elements between donuts2 and donuts1 = ${donuts2 & donuts1}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/IsEmpty_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use IsEmpty Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-isempty-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object IsEmpty_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to find out if a sequence is empty using isEmpty function")
println(s"Is donuts sequence empty = ${donuts.isEmpty}")
println("\nStep 3: How to create an empty sequence")
val donuts2: Seq[String] = Seq.empty[String]
println(s"Elements of donuts2 = $donuts2")
println("\nStep 4: How to find out if a sequence is empty using isEmpty function")
println(s"Is donuts2 sequence empty = ${donuts2.isEmpty}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Last_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Last Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-last-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Last_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to access the last element of the donut sequence by index")
println(s"Last element of donut sequence = ${donuts(donuts.size - 1)}")
println("\nStep 3: How to access the last element of the donut sequence by using the last function")
println(s"Last element of donut sequence = ${donuts.last}")
println("\nStep 4: How to create an empty sequence")
val donuts2: Seq[String] = Seq.empty[String]
println(s"Elements of donuts2 = $donuts2")
println("\nStep 5: How to access the last element of the donut sequence using the lastOption function")
println(s"Last element of empty sequence = ${donuts2.lastOption.getOrElse("No donut was found!")}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Map_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Map Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-map-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Map_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts1: Seq[String] = Seq("Plain", "Strawberry", "Glazed")
println(s"Elements of donuts1 = $donuts1")
println("\nStep 2: How to append the word Donut to each element using the map function")
val donuts2: Seq[String] = donuts1.map(_ + " Donut")
println(s"Elements of donuts2 = $donuts2")
println("\nStep 3: How to create a donut sequence with one None element")
val donuts3: Seq[AnyRef] = Seq("Plain", "Strawberry", None)
donuts3.foreach(println(_))
println("\nStep 4: How to filter out the None element using map function")
val donuts4: Seq[String] = donuts3.map {
case donut: String => donut + " Donut"
case None => "Unknown Donut"
}
println(s"Elements of donuts4 = $donuts4")
println("\nStep 5: How to define couple of functions which returns an Option of type String")
def favoriteDonut: Option[String] = Some("Glazed Donut")
def leastFavoriteDonut: Option[String] = None
println("\nStep 6: How to use map function to filter out None values")
favoriteDonut.map(donut => println(s"Favorite donut = $donut"))
leastFavoriteDonut.map(donut=> println(s"Least favorite donut = $donut"))
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/MaxBy_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use MaxBy Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-maxby-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object MaxBy_Tutorial extends App {
println("Step 1: How to create a case class to represent Donut object")
case class Donut(name: String, price: Double)
println("\nStep 2: How to create a Sequence of type Donut")
val donuts: Seq[Donut] = Seq(Donut("Plain Donut", 1.5), Donut("Strawberry Donut", 2.0), Donut("Glazed Donut", 2.5))
println(s"Elements of donuts = $donuts")
println("\nStep 3: How to find the maximum element in a sequence of case classes objects using the maxBy function")
println(s"Maximum element in sequence of case class of type Donut, ordered by price = ${donuts.maxBy(donut => donut.price)}")
println("\nStep 4: How to declare a value predicate function for maxBy function")
val donutsMaxBy: (Donut) => Double = (donut) => donut.price
println(s"Value function donutMaxBy = $donutsMaxBy")
println("\nStep 5: How to find the maximum element using maxBy function and pass through the predicate function from Step 4")
println(s"Maximum element in sequence using function from Step 3 = ${donuts.maxBy(donutsMaxBy)}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Max_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Max Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-max-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Max_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to find the maximum element in the sequence using the max function")
println(s"Max element in the donuts sequence = ${donuts.max}")
println("\nStep 3: How to initialize donut prices")
val prices: Seq[Double] = Seq(1.50, 2.0, 2.50)
println(s"Elements of prices = $prices")
println("\nStep 4: How to find the maximum element in the sequence using the max function")
println(s"Max element in the donut prices sequence = ${prices.max}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/MinBy_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use MinBy Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-minby-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object MinBy_Tutorial extends App {
println("Step 1: How to create case class to represent Donut object")
case class Donut(name: String, price: Double)
println("\nStep 2: How to create a Sequence of type Donut")
val donuts: Seq[Donut] = Seq(Donut("Plain Donut", 1.5), Donut("Strawberry Donut", 2.0), Donut("Glazed Donut", 2.5))
println(s"Elements of donuts = $donuts")
println("\nStep 3: How to find the minimum element in a sequence of case classes using the minBy function")
println(s"Minimum element in sequence of case class of type Donut, ordered by price = ${donuts.minBy(donut => donut.price)}")
println("\nStep 4: How to declare a value predicate function for minBy function")
val donutsMinBy: (Donut) => Double = (donut) => donut.price
println(s"Value function donutMinBy = $donutsMinBy")
println("\nStep 5: How to find the minimum element using minBy function and passing through the predicate function from Step 4")
println(s"Minimum element in sequence using function from Step 3 = ${donuts.minBy(donutsMinBy)}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Min_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Min Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-min-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Min_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to find the minimum element in the sequence using the min function")
println(s"Min element in the donuts sequence = ${donuts.min}")
println("\nStep 3: How to initialize a Sequence of donut prices")
val prices: Seq[Double] = Seq(1.50, 2.0, 2.50)
println(s"Elements of prices = $prices")
println("\nStep 4: How to find the minimum element in the sequence using the min function")
println(s"Min element in the donut prices sequence = ${prices.min}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/MkString_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use MkString Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-mkstring-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object MkString_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to concatenate the elements of a sequence into a String using mkString function")
val donutsAsString: String = donuts.mkString(" and ")
println(s"Donuts elements using mkString function = $donutsAsString")
println("\nStep 3: How to concatenate the elements of a sequence into a String using mkString and specifying prefix and suffix")
val donutsWithPrefixAndSuffix: String = donuts.mkString("My favorite donuts namely ", " and ", " are very tasty!")
println(s"$donutsWithPrefixAndSuffix")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/NonEmpty_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use NonEmpty Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-nonempty-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object NonEmpty_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to check if a sequence is not empty using nonEmpty function")
println(s"Is donuts sequence NOT empty = ${donuts.nonEmpty}")
println("\nStep 3: How to create an empty sequence")
val emptyDonuts: Seq[String] = Seq.empty[String]
println(s"Elements of emptyDonuts = $emptyDonuts")
println("\nStep 4: How to find out if sequence is empty using nonEmpty function")
println(s"Is emptyDonuts sequence empty = ${emptyDonuts.nonEmpty}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Par_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Par Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-par-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Par_Tutorial extends App {
println("Step 1: How to initialize an Immutable Sequence of various donut flavours")
val donutFlavours: Seq[String] = Seq("Plain", "Strawberry", "Glazed")
println(s"Elements of donutFlavours immutable sequence = $donutFlavours")
println("\nStep 2: Convert the Immutable donut flavours Sequence into Parallel Collection")
import scala.collection.parallel.ParSeq
val donutFlavoursParallel: ParSeq[String] = donutFlavours.par
println("\nStep 3: How to use Scala Parallel Collection")
val donuts: ParSeq[String] = donutFlavoursParallel.map(d => s"$d donut")
println(s"Elements of donuts parallel collection = $donuts")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Partition_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Partition Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-partition-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Partition_Tutorial extends App {
println("Step 1: How to initialize a sequence which contains donut names and prices")
val donutNamesAndPrices: Seq[Any] = Seq("Plain Donut", 1.5, "Strawberry Donut", 2.0, "Glazed Donut", 2.5)
println(s"Elements of donutNamesAndPrices = $donutNamesAndPrices")
println("\nStep 2: How to split the sequence by the element types using partition function")
val namesAndPrices: (Seq[Any], Seq[Any]) = donutNamesAndPrices.partition {
case name: String => true
case price: Double => false
}
println(s"Elements of namesAndPrices = $namesAndPrices")
println("\nStep 3: How to access the donut String sequence from Step 2")
println(s"Donut names = ${namesAndPrices._1}")
println("\nStep 4: How to access the donut prices sequence from Step 2")
println(s"Donut prices = ${namesAndPrices._2}")
println("\nStep 5: How to extract the pair returned by partition function")
val (donutNames, donutPrices) = donutNamesAndPrices.partition {
case name: String => true
case _ => false
}
println(s"donutNames = $donutNames")
println(s"donutPrices = $donutPrices")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ReduceLeft_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use ReduceLeft Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reduceleft-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object ReduceLeft_Tutorial extends App {
println("Step 1: How to initialize a sequence of donut prices")
val donutPrices: Seq[Double] = Seq(1.5, 2.0, 2.5)
println(s"Elements of donutPrices = $donutPrices")
println("\nStep 2: How to find the sum of the elements using reduceLeft function")
val sum: Double = donutPrices.reduceLeft(_ + _)
println(s"Sum of elements from donutPrices = $sum")
println("\nStep 3: How to find the sum of elements using reduceLeft function explicitly")
val sum1: Double = donutPrices.reduceLeft((a, b) => a + b)
println(s"Sum of elements from donutPrices by calling reduceLeft function explicitly= $sum1")
println("\nStep 4: How to find the cheapest donut using reduceLeft function")
println(s"Cheapest donut price = ${donutPrices.reduceLeft(_ min _)}")
println("\nStep 5: How to find the most expensive donut using reduceLeft function")
println(s"Most expensive donut price = ${donutPrices.reduceLeft(_ max _)}")
println("\nStep 6: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 7: How to concatenate the elements from the sequence using reduceLeft function")
println(s"Elements of donuts sequence concatenated = ${donuts.reduceLeft((left, right) => left + ", " + right)}")
println("\nStep 8: How to declare a value function to concatenate donut names")
val concatDonutNames: (String, String) => String = (left, right) => {
left + ", " + right
}
println(s"Value function concatDonutNames = $concatDonutNames")
println("\nStep 9: How to pass a function to reduceLeft function")
println(s"Elements of donuts sequence concatenated by passing function to the reduceLeft function = ${donuts reduceLeft concatDonutNames}")
println("\nStep 10: How to use reduceLeftOption to avoid exception if the collection is empty ")
println(s"Using reduceLeftOption will NOT throw any exception = ${Seq.empty[String].reduceLeftOption(_ + ", " + _)}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ReduceRight_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use ReduceRight Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reduceright-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object ReduceRight_Tutorial extends App {
println("Step 1: How to initialize a sequence of donut prices")
val donutPrices: Seq[Double] = Seq(1.5, 2.0, 2.5)
println(s"Elements of donutPrices = $donutPrices")
println("\nStep 2: How to find the sum of the elements using reduceRight function")
val sum: Double = donutPrices.reduceRight(_ + _)
println(s"Sum of elements from donutPrices = $sum")
println("\nStep 3: How to find the sum of elements using reduceRight function explicitly")
val sum1: Double = donutPrices.reduceRight((a, b) => a + b)
println(s"Sum of elements from donutPrices by calling reduceRight function explicitly= $sum1")
println("\nStep 4: How to find the cheapest donut using reduceRight function")
println(s"Cheapest donut price = ${donutPrices.reduceRight(_ min _)}")
println("\nStep 5: How to find the most expensive donut using reduceRight function")
println(s"Most expensive donut price = ${donutPrices.reduceRight(_ max _)}")
println("\nStep 6: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 7: How to concatenate the elements from the sequence using reduceRight function")
println(s"Elements of donuts sequence concatenated = ${donuts.reduceRight((left, right) => left + ", " + right)}")
println("\nStep 8: How to declare a value function to concatenate donut names")
val concatDonutNames: (String, String) => String = (left, right) => {
left + ", " + right
}
println(s"Value function concatDonutNames = $concatDonutNames")
println("\nStep 9: How to pass a function to reduceRight function")
println(s"Elements of donuts sequence concatenated by passing function to the reduce function = ${donuts reduceRight concatDonutNames}")
println("\nStep 10: How to use option reduce right function to avoid exception if collection is empty")
println(s"Using reduce right option will NOT throw any exception = ${Seq.empty[String].reduceRightOption(_ + ", " + _)}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Reduce_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Reduce Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reduce-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Reduce_Tutorial extends App {
println("Step 1: How to initialize a sequence of donut prices")
val donutPrices: Seq[Double] = Seq(1.5, 2.0, 2.5)
println(s"Elements of donutPrices = $donutPrices")
println("\nStep 2: How to find the sum of the elements using reduce function")
val sum: Double = donutPrices.reduce(_ + _)
println(s"Sum of elements from donutPrices = $sum")
println("\nStep 3: How to find the sum of elements using reduce function explicitly")
val sum1: Double = donutPrices.reduce((a, b) => a + b)
println(s"Sum of elements from donutPrices by calling reduce function explicitly= $sum1")
println("\nStep 4: How to find the cheapest donut using reduce function")
println(s"Cheapest donut price = ${donutPrices.reduce(_ min _)}")
println("\nStep 5: How to find the most expensive donut using reduce function")
println(s"Most expensive donut price = ${donutPrices.reduce(_ max _)}")
println("\nStep 6: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 7: How to concatenate the elements from the sequence using reduce function")
println(s"Elements of donuts sequence concatenated = ${donuts.reduce((left, right) => left + ", " + right)}")
println("\nStep 8: How to declare a value function to concatenate donut names")
val concatDonutNames: (String, String) => String = (left, right) => {
left + ", " + right
}
println(s"Value function concatDonutNames = $concatDonutNames")
println("\nStep 9: How to pass a function to reduce function")
println(s"Elements of donuts sequence concatenated by passing function to the reduce function = ${donuts reduce concatDonutNames}")
println("\nStep 10: How to use option reduce to avoid exception if the collection is empty ")
println(s"Using reduce option will NOT throw any exception = ${Seq.empty[String].reduceOption(_ + ", " + _)}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ReverseIterator.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use ReverseIterator Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reverseiterator-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object ReverseIterator extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to print all elements in reverse order using reverseIterator function")
println(s"Elements of donuts in reversed order = ${donuts.reverseIterator.toList}")
println("\nStep 3: How to iterate through elements using foreach method")
val reverseIterator: Iterator[String] = donuts.reverseIterator
reverseIterator.foreach(donut => println(s"donut = $donut"))
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Reverse_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Reverse Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reverse-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Reverse_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to get the elements of the sequence in reverse using the reverse method")
println(s"Elements of donuts in reversed order = ${donuts.reverse}")
println("\nStep 3: How to access each reversed element using reverse and foreach methods")
donuts.reverse.foreach(donut => println(s"donut = $donut"))
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ScanLeft_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use ScanLeft Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-scanleft-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object ScanLeft_Tutorial extends App {
println("Step 1: How to initialize a sequence of numbers")
val numbers: Seq[Int] = Seq(1, 2, 3, 4, 5)
println(s"Elements of numbers = $numbers")
println("\nStep 2: How to create a running total using the scanLeft function")
val runningTotal: Seq[Int] = numbers.scanLeft(0)(_ + _)
println(s"Running total of all elements in the collection = $runningTotal")
// NOTE: scanLeft method iterations
// 0 + 1 = 1
// 1 + 2 = 3
// 1 + 2 + 3 = 6
// 1 + 2 + 3 + 4 = 10
// 1 + 2 + 3 + 4 + 5 = 15
println("\nStep 3: How to create a running total using the scanLeft function explicitly")
val runningTotal2: Seq[Int] = numbers.scanLeft(0)((a, b) => a + b)
println(s"Running total of all elements in the collection = $runningTotal2")
// NOTE: scanLeft method iterations
// 0 + 1 = 1
// 1 + 2 = 3
// 1 + 2 + 3 = 6
// 1 + 2 + 3 + 4 = 10
// 1 + 2 + 3 + 4 + 5 = 15
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ScanRight_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use ScanRight Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-scanright-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object ScanRight_Tutorial extends App {
println("Step 1: How to initialize a sequence of numbers")
val numbers: Seq[Int] = Seq(1, 2, 3, 4, 5)
println(s"Elements of numbers = $numbers")
println("\nStep 2: How to create a running total using the scanRight function")
val runningTotal: Seq[Int] = numbers.scanRight(0)(_ + _)
println(s"Running total of all elements in the collection = $runningTotal")
// NOTE: scanRight method iterations
// 5 + 4 + 3 + 2 + 1 = 15
// 5 + 4 + 3 + 2 = 14
// 5 + 4 + 3 = 12
// 5 + 4 = 9
// 5 + 0 = 5
// 0 = 0
println("\nStep 3: How to create a running total using the scanRight function explicitly")
val runningTotal2: Seq[Int] = numbers.scanRight(0)((a, b) => a + b)
println(s"Running total of all elements in the collection = $runningTotal2")
// NOTE: scanRight method iterations
// 5 + 4 + 3 + 2 + 1 = 15
// 5 + 4 + 3 + 2 = 14
// 5 + 4 + 3 = 12
// 5 + 4 = 9
// 5 + 0 = 5
// 0 = 0
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Scan_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Scan Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-scan-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Scan_Tutorial extends App {
println("Step 1: How to initialize a sequence of numbers")
val numbers: Seq[Int] = Seq(1, 2, 3, 4, 5)
println(s"Elements of numbers = $numbers")
println("\nStep 2: How to create a running total using the scan function")
val runningTotal: Seq[Int] = numbers.scan(0)(_ + _)
println(s"Running total of all elements in the collection = $runningTotal")
// NOTE: scan method iterations
// 0 + 1 = 1
// 1 + 2 = 3
// 1 + 2 + 3 = 6
// 1 + 2 + 3 + 4 = 10
// 1 + 2 + 3 + 4 + 5 = 15
println("\nStep 3: How to create a running total using the scan function explicitly")
val runningTotal2: Seq[Int] = numbers.scan(0)((a, b) => a + b)
println(s"Running total of all elements in the collection = $runningTotal2")
// NOTE: scan method iterations
// 0 + 1 = 1
// 1 + 2 = 3
// 1 + 2 + 3 = 6
// 1 + 2 + 3 + 4 = 10
// 1 + 2 + 3 + 4 + 5 = 15
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Size_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Size Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-size-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Size_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to count the number of elements in the sequence using size function")
println(s"Size of donuts sequence = ${donuts.size}")
println("\nStep 3: How to use the count function")
println(s"Number of times element Plain Donut appear in donuts sequence = ${donuts.count(_ == "Plain Donut")}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Slice_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Slice Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-slice-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Slice_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to take a section from the sequence using the slice function")
println(s"Take elements from the sequence from index 0 to 1 = ${donuts.slice(0,1)}")
println(s"Take elements from the sequence from index 0 to 2 = ${donuts.slice(0,2)}")
println(s"Take elements from the sequence from index 0 to 3 = ${donuts.slice(0,3)}")
println("\nStep 3: How to use slice function where the index is out of range")
println(s"Take elements from the sequence from index 0 to 4 = ${donuts.slice(0,4)}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/SortBy_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use SortBy Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-sortby-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object SortBy_Tutorial extends App {
println("\nStep 1: How to create a case class to represent Donut objects")
case class Donut(name: String, price: Double)
println("\nStep 2: How to create a Sequence of type Donut")
val donuts: Seq[Donut] = Seq(Donut("Plain Donut", 1.5), Donut("Strawberry Donut", 2.0), Donut("Glazed Donut", 2.5))
println(s"Elements of donuts = $donuts")
println("\nStep 3: How to sort a sequence of case class objects using the sortBy function")
println(s"Sort a sequence of case class objects of type Donut, sorted by price = ${donuts.sortBy(donut => donut.price)}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/SortWith_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use SortWith Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-sortwith-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object SortWith_Tutorial extends App {
println("\nStep 1: How to create a case class to represent Donut objects")
case class Donut(name: String, price: Double)
println("\nStep 2: How to create a Sequence of type Donut")
val donuts: Seq[Donut] = Seq(Donut("Plain Donut", 1.5), Donut("Strawberry Donut", 2.0), Donut("Glazed Donut", 2.5))
println(s"Elements of donuts = $donuts")
println("\nStep 3: How to sort a sequence of case class objects using the sortWith function")
println(s"Sort a sequence of case classes of type Donut, sorted with price = ${donuts.sortWith(_.price < _.price)}")
println("\nStep 4: How to sort a sequence of case class objects in ascending order using the sortWith function")
println(s"Sort a sequence of case classes of type Donut, sorted with price in ascending order = ${donuts.sortWith(_.price < _.price)}")
println(s"Sort a sequence of case classes of type Donut, sorted with price in ascending order explicitly = ${donuts.sortWith((d1,d2) => d1.price < d2.price)}")
println("\nStep 5: How to sort a sequence of case class objects in descending order using the sortWith function")
println(s"Sort a sequence of case classes of type Donut, sorted with price in descending order = ${donuts.sortWith(_.price > _.price)}")
println(s"Sort a sequence of case classes of type Donut, sorted with price in descending order explicitly = ${donuts.sortWith((d1,d2) => d1.price > d2.price)}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Sorted_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Sorted Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-sorted-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Sorted_Tutorial extends App {
println("Step 1: How to initialize donut prices")
val prices: Seq[Double] = Seq(1.50, 2.0, 2.50)
println(s"Elements of prices = $prices")
println("\nStep 2: How to sort a sequence of type Double using the sorted function")
println(s"Sort a sequence of type Double by their natural ordering = ${prices.sorted}")
println("\nStep 3: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 4: How to sort a sequence of type String using the sorted function")
println(s"Sort a sequence of type String by their natural ordering = ${donuts.sorted}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Tail_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Tail Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-tail-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Tail_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to return all elements in the sequence except the head using the tail function")
println(s"Elements of donuts excluding the head = ${donuts.tail}")
println("\nStep 3: How to access the last element of the donut sequence by using the last function")
println(s"Last element of donut sequence = ${donuts.last}")
println("\nStep 4: How to access the first element of the donut sequence by using the head function")
println(s"First element of donut sequence = ${donuts.head}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/TakeRight_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use TakeRight Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-takeright-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object TakeRight_Tutorial extends App {
println("Step 1: How to initialize a List of donuts")
val donuts: Seq[String] = List("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to take the last N elements using the takeRight function")
println(s"Take the last donut element in the sequence = ${donuts.takeRight(1)}")
println(s"Take the last two donut elements in the sequence = ${donuts.takeRight(2)}")
println(s"Take the last three donut elements in the sequence = ${donuts.takeRight(3)}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/TakeWhile_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use TakeWhile Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-takewhile-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object TakeWhile_Tutorial extends App {
println("Step 1: How to initialize a List of donuts")
val donuts: Seq[String] = List("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to take elements from the List using the takeWhile function")
println(s"Take donut elements which start with letter P = ${donuts.takeWhile(_.charAt(0) == 'P')}")
println("\nStep 3: How to declare a predicate function to be passed-through to the takeWhile function")
val takeDonutPredicate: (String) => Boolean = (donutName) => donutName.charAt(0) == 'P'
println(s"Value function takeDonutPredicate = $takeDonutPredicate")
println("\nStep 4: How to take elements using the predicate function from Step 3")
println(s"Take elements using function from Step 3 = ${donuts.takeWhile(takeDonutPredicate)}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Take_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Take Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-take-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Take_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to take elements from the sequence using the take function")
println(s"Take the first donut element in the sequence = ${donuts.take(1)}")
println(s"Take the first and second donut elements in the sequence = ${donuts.take(2)}")
println(s"Take the first, second and third donut elements in the sequence = ${donuts.take(3)}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Transpose_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Transpose Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-transpose-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Transpose_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to initialize donut prices")
val prices: Seq[Double] = Seq(1.50, 2.0, 2.50)
println(s"Elements of prices = $prices")
println("\nStep 3: How to create a List of donuts and prices")
val donutList = List(donuts, prices)
println(s"Sequence of donuts and prices = $donutList")
println("\nStep 4: How to pair each element from both donuts and prices Sequences using the transpose function")
println(s"Transposed list of donuts paired with their individual prices = ${donutList.transpose}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Union_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Union Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-union-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Union_Tutorial extends App {
println("Step 1: How to initialize a Set of donuts")
val donuts1: Set[String] = Set("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts1 = $donuts1")
println("\nStep 2: How to initialize another Set of donuts")
val donuts2: Set[String] = Set("Plain Donut", "Chocolate Donut", "Vanilla Donut")
println(s"Elements of donuts2 = $donuts2")
println("\nStep 3: How to merge two Sets using union function")
println(s"Union of Sets donuts1 and donuts2 = ${donuts1 union donuts2}")
println(s"Union of Sets donuts2 and donuts1 = ${donuts2 union donuts1}")
println("\nStep 4: How to merge two Sets using ++ function")
println(s"Union of Sets donuts1 and donuts2 = ${donuts1 ++ donuts2}")
println(s"Union of Sets donuts2 and donuts1 = ${donuts2 ++ donuts1}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Unzip3_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Unzip3 Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-unzip3-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Unzip3_Tutorial extends App {
println("Step 1: How to initialize a Sequence of Tuple3 elements")
val donuts: Seq[(String, Double, String)] = Seq(("Plain Donut",1.5,"Tasty"), ("Glazed Donut",2.0,"Very Tasty"), ("Strawberry Donut",2.5,"Very Tasty"))
println(s"Donuts tuple3 elements = $donuts")
println("\nStep 2: How to call unzip3 function to unzip Tuple3 elements")
val unzipped: (Seq[String], Seq[Double], Seq[String]) = donuts.unzip3
println(s"Unzipped donut names = ${unzipped._1}")
println(s"Unzipped donut prices = ${unzipped._2}")
println(s"Unzipped donut taste = ${unzipped._3}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Unzip_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Unzip Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-unzip-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Unzip_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to initialize a Sequence of donut prices")
val donutPrices = Seq[Double](1.5, 2.0, 2.5)
println(s"Elements of donut prices = $donutPrices")
println("\nStep 3: How to zip the donuts Sequence with their corresponding prices")
val zippedDonutsAndPrices: Seq[(String, Double)] = donuts zip donutPrices
println(s"Zipped donuts and prices = $zippedDonutsAndPrices")
println("\nStep 4: How to unzip the zipped donut sequence into separate donuts names and prices Sequences")
val unzipped: (Seq[String], Seq[Double]) = zippedDonutsAndPrices.unzip
println(s"Donut names unzipped = ${unzipped._1}")
println(s"Donut prices unzipped = ${unzipped._2}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ViewTutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use View Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-view-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object ViewTutorial extends App {
println("Step 1: How to create a large numeric range and take the first 10 odd numbers")
val largeOddNumberList: List[Int] = (1 to 1000000).filter(_ % 2 != 0).take(10).toList
println(s"First 100 odd numbers from largeOddNumberList = ${largeOddNumberList}")
println(s"\nStep 2: How to lazily create a large numeric range and take the first 10 odd numbers")
val lazyLargeOddNumberList = (1 to 1000000).view.filter(_ % 2 != 0).take(10).toList
println(s"Lazily take the first 100 odd numbers from lazyLargeOddNumberList = ${lazyLargeOddNumberList}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/WithFilter_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use WithFilter Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-withfilter-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object WithFilter_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = List("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to filter elements using the withFilter function")
donuts
.withFilter(_.charAt(0) == 'P')
.foreach(donut => println(s"Donut starting with letter P = $donut"))
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ZipWIthIndex.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use ZipWithIndex Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-zipwithindex-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object ZipWIthIndex extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to zip the donuts Sequence with their corresponding index using zipWithIndex method")
val zippedDonutsWithIndex: Seq[(String, Int)] = donuts.zipWithIndex
zippedDonutsWithIndex.foreach{ donutWithIndex =>
println(s"Donut element = ${donutWithIndex._1} is at index = ${donutWithIndex._2}")
}
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Zip_Tutorial.scala
================================================
package com.allaboutscala.chapter.eight
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Zip Function With Examples
*
* [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-zip-example/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object Zip_Tutorial extends App {
println("Step 1: How to initialize a Sequence of donuts")
val donuts: Seq[String] = Seq("Plain Donut", "Strawberry Donut", "Glazed Donut")
println(s"Elements of donuts = $donuts")
println("\nStep 2: How to initialize a Sequence of donut prices")
val donutPrices: Seq[Double] = Seq(1.5, 2.0, 2.5)
println(s"Elements of donut prices = $donutPrices")
println("\nStep 3: How to use zip method to zip two collections")
val zippedDonutsAndPrices: Seq[(String, Double)] = donuts zip donutPrices
println(s"Zipped donuts and prices = $zippedDonutsAndPrices")
println("\nStep 4: How to use unzip method to un-merge a zipped collections")
val unzipped: (Seq[String], Seq[Double]) = zippedDonutsAndPrices.unzip
println(s"Donut names unzipped = ${unzipped._1}")
println(s"Donut prices unzipped = ${unzipped._2}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/five/ExtendMultipleTraits.scala
================================================
package com.allaboutscala.chapter.five
/**
* /**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Extend Multiple Traits
*
* [[http://allaboutscala.com/tutorials/chapter-5-traits/scala-extend-multiple-traits/]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
*/
object ExtendMultipleTraits extends App {
println("Step 1: Create a trait with type which will define the methods for a data access layer")
trait DonutShoppingCartDao[A] {
def add(donut: A): Long
def update(donut: A): Boolean
def search(donut: A): A
def delete(donut: A): Boolean
}
println("\nStep 2: Create a second trait which will define the methods for checking donut inventory")
trait DonutInventoryService[A] {
def checkStockQuantity(donut: A): Int
}
println("\nStep 3: Create a DonutShoppingCart class which extends multiple traits namely trait DonutShoppingCartDao and trait DonutInventoryService")
class DonutShoppingCart[A] extends DonutShoppingCartDao[A] with DonutInventoryService[A] {
override def add(donut: A): Long = {
println(s"DonutShoppingCart-> add method -> donut: $donut")
1
}
override def update(donut: A): Boolean = {
println(s"DonutShoppingCart-> update method -> donut: $donut")
true
}
override def search(donut: A): A = {
println(s"DonutShoppingCart-> search method -> donut: $donut")
donut
}
override def delete(donut: A): Boolean = {
println(s"DonutShoppingCart-> delete method -> donut: $donut")
true
}
override def checkStockQuantity(donut: A): Int = {
println(s"DonutShoppingCart-> checkStockQuantity method -> donut: $donut")
10
}
}
println("\nStep 4: Create an instance of DonutShoppingCart and call the add, update, search and delete methods")
val donutShoppingCart: DonutShoppingCart[String] = new DonutShoppingCart[String]()
donutShoppingCart.add("Vanilla Donut")
donutShoppingCart.update("Vanilla Donut")
donutShoppingCart.search("Vanilla Donut")
donutShoppingCart.delete("Vanilla Donut")
println("\nStep 5: Call the checkStockQuantity method which was inherited from trait DonutInventoryService")
donutShoppingCart.checkStockQuantity("Vanilla Donut")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/five/ExtendTrait_Tutorial.scala
================================================
package com.allaboutscala.chapter.five
/**
* /**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Extend Trait In Scala
*
* [[http://allaboutscala.com/tutorials/chapter-5-traits/scala-extend-trait/]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
*/
object ExtendTrait_Tutorial extends App {
println("Step 1: Create a trait which will define the methods for a data access layer")
trait DonutShoppingCartDao {
def add(donutName: String): Long
def update(donutName: String): Boolean
def search(donutName: String): String
def delete(donutName: String): Boolean
}
println("\nStep 2: Create a DonutShoppingCart class which extends the trait from Step 1 and implements its methods")
class DonutShoppingCart extends DonutShoppingCartDao {
override def add(donutName: String): Long = {
println(s"DonutShoppingCart-> add method -> donutName: $donutName")
1
}
override def update(donutName: String): Boolean = {
println(s"DonutShoppingCart-> update method -> donutName: $donutName")
true
}
override def search(donutName: String): String = {
println(s"DonutShoppingCart-> search method -> donutName: $donutName")
donutName
}
override def delete(donutName: String): Boolean = {
println(s"DonutShoppingCart-> delete method -> donutName: $donutName")
true
}
}
println("\nStep 3: Create an instance of DonutShoppingCart and call the add, update, search and delete methods")
val donutShoppingCart1: DonutShoppingCart = new DonutShoppingCart()
donutShoppingCart1.add("Vanilla Donut")
donutShoppingCart1.update("Vanilla Donut")
donutShoppingCart1.search("Vanilla Donut")
donutShoppingCart1.delete("Vanilla Donut")
println("\nStep 4: Create an instance of DonutShoppingCart and assign its type to the trait DonutShoppingCartDao")
val donutShoppingCart2: DonutShoppingCartDao = new DonutShoppingCart()
donutShoppingCart2.add("Vanilla Donut")
donutShoppingCart2.update("Vanilla Donut")
donutShoppingCart2.search("Vanilla Donut")
donutShoppingCart2.delete("Vanilla Donut")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/five/TraitDependencyInjectionPartTwo_Tutorial.scala
================================================
package com.allaboutscala.chapter.five
/**
* /**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Traits For Dependency Injection Part 2 - Avoid Cake Pattern
*
* [[http://allaboutscala.com/tutorials/chapter-5-traits/scala-traits-depedency-injection-avoid-cake-pattern/]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
*/
object TraitDependencyInjectionPartTwo_Tutorial extends App {
println("Step 1: How to define a class to encapsulate inventory services")
class DonutInventoryService[T] {
def checkStock(donut: T): Boolean = {
println("DonutInventoryService->checkStock")
true
}
}
println("\nStep 2: How to define a class to encapsulate pricing services")
class DonutPricingService[T] {
def calculatePrice(donut: T): Double = {
println("DonutPricingService->calculatePrice")
2.50
}
}
println("\nStep 3: How to define a class to encapsulate creating a donut order")
class DonutOrderService[T] {
def createOrder(donut: T, quantity: Int, price: Double): Int = {
println(s"Saving donut order to database: donut = $donut, quantity = $quantity, price = $price")
100 // the id of the booked order
}
}
println("\nStep 4: How to define a class to encapsulate shopping cart services")
class DonutShoppingCartService[T] (
donutInventoryService: DonutInventoryService[T],
donutPricingService: DonutPricingService[T],
donutOrderService: DonutOrderService[T]) {
def bookOrder(donut: T, quantity: Int): Int = {
println("DonutShoppingCartService->bookOrder")
donutInventoryService.checkStock(donut) match {
case true =>
val price = donutPricingService.calculatePrice(donut)
donutOrderService.createOrder(donut, quantity, price) // the id of the booked order
case false =>
println(s"Sorry donut $donut is out of stock!")
-100 // return some error code to identify out of stock
}
}
}
println("\nStep 5: How to define a trait to encapsulate all the services for Donut store")
trait DonutStoreServices {
val donutInventoryService = new DonutInventoryService[String]
val donutPricingService = new DonutPricingService[String]
val donutOrderService = new DonutOrderService[String]
val donutShoppingCartService = new DonutShoppingCartService(donutInventoryService, donutPricingService, donutOrderService)
}
println("\nStep 6: How to define a facade to expose functionality of DonutStoreServices")
trait DonutStoreAppController {
this: DonutStoreServices =>
def bookOrder(donut: String, quantity: Int): Int = {
println("DonutStoreAppController->bookOrder")
donutShoppingCartService.bookOrder(donut, quantity)
}
}
println("\nStep 7: How to create a Donut store app which extends facade from Step 5 and injects the required donut services from Step 4")
object DonutStoreApp extends DonutStoreAppController with DonutStoreServices
println("\nStep 8: How to call the bookOrder method of the Donut store app from Step 7")
DonutStoreApp.bookOrder("Vanilla Donut", 10)
println("\nStep 9: Test DonutStoreApp by injecting a mocked version of DonutStoreServices")
trait MockedDonutStoreServices extends DonutStoreServices {
override val donutInventoryService: DonutInventoryService[String] = ???
override val donutPricingService: DonutPricingService[String] = ???
override val donutOrderService: DonutOrderService[String] = ???
override val donutShoppingCartService: DonutShoppingCartService[String] = new DonutShoppingCartService[String](
donutInventoryService, donutPricingService, donutOrderService)
}
println("\nStep 1: Create a Mocked Donut Store App and inject mocked donut services")
object MockedDonutStoreApp extends DonutStoreAppController with MockedDonutStoreServices
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/five/TraitDependencyInjection_Tutorial.scala
================================================
package com.allaboutscala.chapter.five
/**
* /**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Traits For Dependency Injection
*
* [[http://allaboutscala.com/tutorials/chapter-5-traits/scala-traits-depedency-injection/]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
*/
object TraitDependencyInjection_Tutorial extends App {
println("Step 1: Create a trait which knows how to do create, read, update and delete operations CRUD to a given database")
trait DonutDatabase[A] {
def addOrUpdate(donut: A): Long
def query(donut: A): A
def delete(donut: A): Boolean
}
println("\nStep 2: Create a class which extends trait DonutDatabase and knows how to perform CRUD operations with Apache Cassandra as storage layer")
class CassandraDonutStore[A] extends DonutDatabase[A] {
override def addOrUpdate(donut: A): Long = {
println(s"CassandraDonutDatabase-> addOrUpdate method -> donut: $donut")
1
}
override def query(donut: A): A = {
println(s"CassandraDonutDatabase-> query method -> donut: $donut")
donut
}
override def delete(donut: A): Boolean = {
println(s"CassandraDonutDatabase-> delete method -> donut: $donut")
true
}
}
println("\nStep 3: Create a trait which will define the methods for a data access layer and will require dependency injection for DonutDatabase")
trait DonutShoppingCartDao[A] {
val donutDatabase: DonutDatabase[A] // dependency injection
def add(donut: A): Long = {
println(s"DonutShoppingCartDao-> add method -> donut: $donut")
donutDatabase.addOrUpdate(donut)
}
def update(donut: A): Boolean = {
println(s"DonutShoppingCartDao-> update method -> donut: $donut")
donutDatabase.addOrUpdate(donut)
true
}
def search(donut: A): A = {
println(s"DonutShoppingCartDao-> search method -> donut: $donut")
donutDatabase.query(donut)
}
def delete(donut: A): Boolean = {
println(s"DonutShoppingCartDao-> delete method -> donut: $donut")
donutDatabase.delete(donut)
}
}
println("\nStep 4: Create a trait which will define the methods for checking donut inventory and will require dependency injection for DonutDatabase")
trait DonutInventoryService[A] {
val donutDatabase: DonutDatabase[A] // dependency injection
def checkStockQuantity(donut: A): Int = {
println(s"DonutInventoryService-> checkStockQuantity method -> donut: $donut")
donutDatabase.query(donut)
1
}
}
println("\nStep 5: Create a trait which will act as a facade which extends multiple traits namely trait DonutShoppingCartDao and trait DonutInventoryService. It also inject the correct DonutDatabase implementation - a CassandraDonutStore")
trait DonutShoppingCartServices[A] extends DonutShoppingCartDao[A] with DonutInventoryService[A] {
override val donutDatabase: DonutDatabase[A] = new CassandraDonutStore[A]()
}
println("\nStep 6: Create a DonutShoppingCart class which extends a single facade named DonutShoppingCartServices to expose all the underlying features required by a DonutShoppingCart")
class DonutShoppingCart[A] extends DonutShoppingCartServices[A] {
}
println("\nStep 7: Create an instance of DonutShoppingCart and call the add, update, search and delete methods")
val donutShoppingCart: DonutShoppingCart[String] = new DonutShoppingCart[String]()
donutShoppingCart.add("Vanilla Donut")
donutShoppingCart.update("Vanilla Donut")
donutShoppingCart.search("Vanilla Donut")
donutShoppingCart.delete("Vanilla Donut")
println("\nStep 8: Call the checkStockQuantity method")
donutShoppingCart.checkStockQuantity("Vanilla Donut")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/five/TraitFactory_Tutorial.scala
================================================
package com.allaboutscala.chapter.five
/**
* /**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Traits, Companion Object, Factory Pattern
*
* [[http://allaboutscala.com/tutorials/chapter-5-traits/scala-traits-companion-object-factory-pattern/]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
*/
object TraitFactory_Tutorial extends App {
// Step 1: Define a wrapper object called Cakes to hold various types of cakes
object Cakes {
// Step 2: Define a base trait to represent a Cake
trait Cake {
def name: String
}
// Step 3: Define class implementations for the Cake trait namely: Cupcake, Donut and UnknownCake
class UnknownCake extends Cake {
override def name: String = "Unknown Cake ... but still delicious!"
}
class Cupcake extends Cake {
override def name: String = "Cupcake"
}
class Donut extends Cake {
override def name: String = "Donut"
}
}
// Step 4: Define a wrapper object called CakeFactory")
object CakeFactory {
import Cakes._
// Step 5: Define an apply method which will act as a factory to produce the correct Cake implementation
def apply(cake: String): Cake = {
cake match {
case "cupcake" => new Cupcake
case "donut" => new Donut
case _ => new UnknownCake
}
}
}
// Step 6: Call the CakeFactory
println(s"A cupcake = ${CakeFactory("cupcake").name}")
println(s"A donut = ${CakeFactory("donut").name}")
println(s"Unknown cake = ${CakeFactory("coconut tart").name}")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/five/TraitWithTypes_Tutorial.scala
================================================
package com.allaboutscala.chapter.five
/**
* /**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Create Traits With Type Paramters
*
* [[http://allaboutscala.com/tutorials/chapter-5-traits/scala-trait-type-parameters/]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
*/
object TraitWithTypes_Tutorial extends App {
println("Step 1: Create a trait with type which will define the methods for a data access layer")
trait DonutShoppingCartDao[A] {
def add(donut: A): Long
def update(donut: A): Boolean
def search(donut: A): A
def delete(donut: A): Boolean
}
println("\nStep 2: Create a DonutShoppingCart class of type A which extends the trait from Step 1 and implements its methods")
class DonutShoppingCart[A] extends DonutShoppingCartDao[A] {
override def add(donut: A): Long = {
println(s"DonutShoppingCart-> add method -> donut: $donut")
1
}
override def update(donut: A): Boolean = {
println(s"DonutShoppingCart-> update method -> donut: $donut")
true
}
override def search(donut: A): A = {
println(s"DonutShoppingCart-> search method -> donut: $donut")
donut
}
override def delete(donut: A): Boolean = {
println(s"DonutShoppingCart-> delete method -> donut: $donut")
true
}
}
println("\nStep 3: Create an instance of DonutShoppingCart of type String and call the add, update, search and delete methods")
val donutShoppingCart1: DonutShoppingCart[String] = new DonutShoppingCart[String]()
donutShoppingCart1.add("Vanilla Donut")
donutShoppingCart1.update("Vanilla Donut")
donutShoppingCart1.search("Vanilla Donut")
donutShoppingCart1.delete("Vanilla Donut")
println("\nStep 4: Create an instance of DonutShoppingCart of type String and assign its type to the trait DonutShoppingCartDao")
val donutShoppingCart2: DonutShoppingCartDao[String] = new DonutShoppingCart[String]()
donutShoppingCart2.add("Vanilla Donut")
donutShoppingCart2.update("Vanilla Donut")
donutShoppingCart2.search("Vanilla Donut")
donutShoppingCart2.delete("Vanilla Donut")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/CaseClassInheritance_Tutorial.scala
================================================
package com.allaboutscala.chapter.four
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Extend Case Class - Case Class Inheritance
*
* [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-extend-case-class/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object CaseClassInheritance_Tutorial extends App {
println("Step 1: How to define an abstract class to represent a Donut object")
abstract class Donut(name: String) {
def printName: Unit
}
println("\nStep 2: How to extend the abstract class Donut and define a case class named VanillaDonut")
case class VanillaDonut(name: String) extends Donut(name) {
override def printName: Unit = println(name)
}
println("\nStep 3: How to extend the abstract class Donut and define a case class named VanillaDonut")
case class GlazedDonut(name: String) extends Donut(name) {
override def printName: Unit = println(name)
}
println("\nStep 4: How to instantiate Donut objects")
val vanillaDonut: Donut = VanillaDonut("Vanilla Donut")
vanillaDonut.printName
val glazedDonut: Donut = GlazedDonut("Glazed Donut")
glazedDonut.printName
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/CaseClass_Tutorial.scala
================================================
package com.allaboutscala.chapter.four
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Define And Use Case Class
*
* [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-define-use-case-class/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object CaseClass_Tutorial extends App {
println("Step 1: How to define a case class to represent a Donut object")
case class Donut(name: String, price: Double, productCode: Option[Long] = None)
println("\nStep 2: How to create instances or objects for the Donut case class")
val vanillaDonut: Donut = Donut("Vanilla Donut", 1.50)
val glazedDonut: Donut = Donut("Glazed Donut", 2.0)
println(s"Vanilla Donut = $vanillaDonut")
println(s"Glazed Donut = $glazedDonut")
println("\nStep 3: How to access fields of the Donut object")
println(s"Vanilla Donut name field = ${vanillaDonut.name}")
println(s"Vanilla Donut price field = ${vanillaDonut.price}")
println(s"Vanilla Donut productCode field = ${vanillaDonut.productCode}")
println("\nStep 4: How to modify or update fields of the Donut object")
// vanillaDonut.name = "vanilla donut" // compiler error. fields are immutable by default.
println("\nStep 5: How to define the hashCode and equals method for Donut object")
val shoppingCart: Map[Donut, Int] = Map(vanillaDonut -> 4, glazedDonut -> 3)
println(s"All items in shopping cart = ${shoppingCart}")
println(s"Quantity of vanilla donuts in shopping cart = ${shoppingCart(vanillaDonut)}")
println(s"Quantity of glazed donuts in shopping cart = ${shoppingCart(glazedDonut)}")
println("\nTIP: How to create a new object of Donut by using the copy() method of the case class")
val chocolateVanillaDonut: Donut = vanillaDonut.copy(name = "Chocolate And Vanilla Donut", price = 5.0)
println(s"Chocolate And Vanilla Donut = $chocolateVanillaDonut")
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/CompanionObjectAsFactory_Tutorial.scala
================================================
package com.allaboutscala.chapter.four
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Use Companion Objects' Apply Method As A Factory (Class Hierarchy Via Inheritance)
*
* [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-companion-objects-factory-apply-method-inheritance/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object CompanionObjectAsFactory_Tutorial extends App {
println("Step 1: How to define a simple class to represent a Donut object")
class Donut(name: String, productCode: Option[Long] = None){
def print = println(s"Donut name = $name, productCode = ${productCode.getOrElse(0)}")
}
println("\nStep 2: How to declare class hierarchy through inheritance using extends keyword")
class GlazedDonut(name: String) extends Donut(name)
class VanillaDonut(name: String) extends Donut(name)
println("\nStep 3: How to declare apply method of companion object as a factory")
object Donut {
def apply(name: String): Donut = {
name match {
case "Glazed Donut" => new GlazedDonut(name)
case "Vanilla Donut" => new VanillaDonut(name)
case _ => new Donut(name)
}
}
}
println("\nStep 4: How to call apply method of companion object which is a factory")
val glazedDonut = Donut("Glazed Donut")
println(s"The class type of glazedDonut = ${glazedDonut.getClass}")
glazedDonut.print
val vanillaDonut = Donut("Vanilla Donut")
println(s"The class type of vanillaDonut = ${vanillaDonut.getClass}")
vanillaDonut.print
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/CompanionObjectFields_Tutorial.scala
================================================
package com.allaboutscala.chapter.four
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Declare Values And Fields In Companion Object
*
* [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-declare-value-fields-companion-object/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object CompanionObjectFields_Tutorial extends App {
println("Step 1: How to define a simple class to represent a Donut object")
class Donut(name: String, productCode: Option[Long] = None){
def print = println(s"Donut name = $name, productCode = ${productCode.getOrElse(0)}, uuid = ${Donut.uuid}")
}
println("\nStep 2: How to declare fields and values in companion object")
object Donut {
private val uuid = 1 // we've declared a uuid value and it is also marked as private.
def apply(name: String, productCode: Option[Long]): Donut = {
new Donut(name, productCode)
}
def apply(name: String): Donut = {
new Donut(name)
}
}
println("\nStep 3: How to create instances of the Donut class using the companion object")
val glazedDonut = Donut("Glazed Donut", Some(1111))
val vanillaDonut = Donut("Vanilla Donut")
println("\nStep 4: How to call function on each Donut object")
glazedDonut.print
vanillaDonut.print
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/CompanionObject_Tutorial.scala
================================================
package com.allaboutscala.chapter.four
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Create And Use Companion Objects
*
* [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-create-use-companion-objects/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
object CompanionObject_Tutorial extends App {
println("Step 1: How to define a simple class to represent a Donut object")
class Donut(name: String, productCode: Long){
def print = println(s"Donut name = $name, productCode = $productCode")
}
println("\nStep 2: How to declare a companion object for the Donut class")
object Donut {
def apply(name: String, productCode: Long): Donut = {
new Donut(name, productCode)
}
}
println("\nStep 3: How to create instances of the Donut class using the companion object")
val glazedDonut = Donut("Glazed Donut", 1111)
val vanillaDonut = Donut("Vanilla Donut", 2222)
println("\nStep 4: How to call function on each Donut object")
glazedDonut.print
vanillaDonut.print
}
================================================
FILE: source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/ContraVariance_Tutorial.scala
================================================
package com.allaboutscala.chapter.four
import com.allaboutscala.chapter.four.Covariance_Tutorial.{GlazedDonut, VanillaDonut}
/**
* Created by Nadim Bahadoor on 28/06/2016.
*
* Tutorial: Learn How To Create Contra-Variance Type Class
*
* [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-variance-contra-variance/ Tutorial]]
*
* Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the L
gitextract__67be5e7/
├── .gitignore
├── LICENSE
├── README.md
└── source-code/
└── allaboutscala/
├── .gitignore
├── build.sbt
├── project/
│ ├── build.properties
│ └── plugins.sbt
└── src/
└── main/
└── scala/
└── com/
└── allaboutscala/
└── chapter/
├── eight/
│ ├── Aggregate_Tutorial.scala
│ ├── Collect_Tutorial.scala
│ ├── Diff_Tutorial.scala
│ ├── DropWhile_Tutorial.scala
│ ├── Drop_Tutorial.scala
│ ├── Exists_Tutorial.scala
│ ├── FilterFilterNot_Tutorial.scala
│ ├── Find_Tutorial.scala
│ ├── FlatMap_Tutorial.scala
│ ├── Flatten_Tutorial.scala
│ ├── FoldLeft_Tutorial.scala
│ ├── FoldRight_Tutorial.scala
│ ├── Fold_Tutorial.scala
│ ├── Foreach_Tutorial.scala
│ ├── GroupBy_Tutorial.scala
│ ├── Head_Tutorial.scala
│ ├── Intersect_Tutorial.scala
│ ├── IsEmpty_Tutorial.scala
│ ├── Last_Tutorial.scala
│ ├── Map_Tutorial.scala
│ ├── MaxBy_Tutorial.scala
│ ├── Max_Tutorial.scala
│ ├── MinBy_Tutorial.scala
│ ├── Min_Tutorial.scala
│ ├── MkString_Tutorial.scala
│ ├── NonEmpty_Tutorial.scala
│ ├── Par_Tutorial.scala
│ ├── Partition_Tutorial.scala
│ ├── ReduceLeft_Tutorial.scala
│ ├── ReduceRight_Tutorial.scala
│ ├── Reduce_Tutorial.scala
│ ├── ReverseIterator.scala
│ ├── Reverse_Tutorial.scala
│ ├── ScanLeft_Tutorial.scala
│ ├── ScanRight_Tutorial.scala
│ ├── Scan_Tutorial.scala
│ ├── Size_Tutorial.scala
│ ├── Slice_Tutorial.scala
│ ├── SortBy_Tutorial.scala
│ ├── SortWith_Tutorial.scala
│ ├── Sorted_Tutorial.scala
│ ├── Tail_Tutorial.scala
│ ├── TakeRight_Tutorial.scala
│ ├── TakeWhile_Tutorial.scala
│ ├── Take_Tutorial.scala
│ ├── Transpose_Tutorial.scala
│ ├── Union_Tutorial.scala
│ ├── Unzip3_Tutorial.scala
│ ├── Unzip_Tutorial.scala
│ ├── ViewTutorial.scala
│ ├── WithFilter_Tutorial.scala
│ ├── ZipWIthIndex.scala
│ └── Zip_Tutorial.scala
├── five/
│ ├── ExtendMultipleTraits.scala
│ ├── ExtendTrait_Tutorial.scala
│ ├── TraitDependencyInjectionPartTwo_Tutorial.scala
│ ├── TraitDependencyInjection_Tutorial.scala
│ ├── TraitFactory_Tutorial.scala
│ └── TraitWithTypes_Tutorial.scala
├── four/
│ ├── CaseClassInheritance_Tutorial.scala
│ ├── CaseClass_Tutorial.scala
│ ├── CompanionObjectAsFactory_Tutorial.scala
│ ├── CompanionObjectFields_Tutorial.scala
│ ├── CompanionObject_Tutorial.scala
│ ├── ContraVariance_Tutorial.scala
│ ├── Covariance_Tutorial.scala
│ ├── ExtendClass_Tutorial.scala
│ ├── ImplicitClass_Tutorial.scala
│ ├── PackageObject_Tutorial.scala
│ ├── SimpleClass_Tutorial.scala
│ ├── SingletonObject_Tutorial.scala
│ ├── TypeAlias_Tutorial.scala
│ ├── TypeClass_Tutorial.scala
│ └── package.scala
├── nine/
│ ├── Tutorial_01_Function_With_Future_Return_Type.scala
│ ├── Tutorial_02_Non_Blocking_Future_Result.scala
│ ├── Tutorial_03_Chain_Futures_FlatMap.scala
│ ├── Tutorial_04_Chain_Futures_For_Comprehension.scala
│ ├── Tutorial_05_Future_Option_With_For_Comprehension.scala
│ ├── Tutorial_06_Future_Option_Map.scala
│ ├── Tutorial_07_Composing_Futures.scala
│ ├── Tutorial_08_Future_Sequence.scala
│ ├── Tutorial_09_Future_Traverse.scala
│ ├── Tutorial_10_Future_FoldLeft.scala
│ ├── Tutorial_11_Future_Reduce.scala
│ ├── Tutorial_12_Future_FirstCompletedOf.scala
│ ├── Tutorial_13_Future_Zip.scala
│ ├── Tutorial_14_Future_ZipWith.scala
│ ├── Tutorial_15_Future_AndThen.scala
│ ├── Tutorial_16_Future_Configure_ThreadPool.scala
│ ├── Tutorial_17_Future_Recover.scala
│ ├── Tutorial_18_Future_RecoverWith.scala
│ ├── Tutorial_19_Future_FallbackTo.scala
│ └── Tutorial_20_Future_Promise.scala
├── one/
│ ├── tutorial_04/
│ │ └── HelloWorld.scala
│ ├── tutorial_05/
│ │ └── HelloWorldMain.scala
│ ├── tutorial_06/
│ │ └── HelloWorldWithArguments.scala
│ ├── tutorial_07/
│ │ └── HelloWorldWithArgumentsDebug.scala
│ └── tutorial_10/
│ └── HelloWorldWithScalaLogging.scala
├── seven/
│ ├── MutableArrayBuffer_Tutorial.scala
│ ├── MutableArrayStack_Tutorial.scala
│ ├── MutableArray_Tutorial.scala
│ ├── MutableBitSet_Tutorial.scala
│ ├── MutableHashMap_Tutorial.scala
│ ├── MutableHashSet_Tutorial.scala
│ ├── MutableLinkedHashMap_Tutorial.scala
│ ├── MutableLinkedHashSet_Tutorial.scala
│ ├── MutableListBuffer_Tutorial.scala
│ ├── MutableListMap_Tutorial.scala
│ ├── MutableMap_Tutorial.scala
│ ├── MutableQueue_Tutorial.scala
│ ├── MutableSet_Tutorial.scala
│ ├── MutableSortedSet_Tutorial.scala
│ ├── MutableTreeSet_Tutorial.scala
│ └── PriorityQueue_Tutorial.scala
├── six/
│ ├── ImmutableBitSet_Tutorial.scala
│ ├── ImmutableHashMap_Tutorial.scala
│ ├── ImmutableHashSet_Tutorial.scala
│ ├── ImmutableListMap_Tutorial.scala
│ ├── ImmutableListSet_Tutorial.scala
│ ├── ImmutableList_Tutorial.scala
│ ├── ImmutableMap_Tutorial.scala
│ ├── ImmutableQueue_Tutorial.scala
│ ├── ImmutableSequence_Tutorial.scala
│ ├── ImmutableSet_Tutorial.scala
│ ├── ImmutableSortedSet_Tutorial.scala
│ ├── ImmutableStack_Tutorial.scala
│ ├── ImmutableStream_Tutorial.scala
│ ├── ImmutableTreeMap_Tutorial.scala
│ ├── ImmutableTreeSet_Tutorial.scala
│ └── ImmutableVector_Tutorial.scala
├── three/
│ ├── CreateAndUseFunction_Tutorial.scala
│ ├── FunctionAsValues_Tutorial.scala
│ ├── FunctionByName_Tutorial.scala
│ ├── FunctionCompositionAndThen_Tutorial.scala
│ ├── FunctionCompositionCompose_Tutorial.scala
│ ├── FunctionCurriedParameterGroups_Tutorial.scala
│ ├── FunctionDefinedAsSymbols_Tutorial.scala
│ ├── FunctionHigherOrderAsParameters_Tutorial.scala
│ ├── FunctionRecursiveTailCall_Tutorial.scala
│ ├── FunctionRecursive_Tutorial.scala
│ ├── FunctionTrampoline_Tutorial.scala
│ ├── FunctionWhichIsImplicit_Tutorial.scala
│ ├── FunctionWhichIsNested.scala
│ ├── FunctionWhichIsPartial_Tutorial.scala
│ ├── FunctionWhichIsPolymorphicWithGenericReturnType_Tutorial.scala
│ ├── FunctionWhichIsTyped_Tutorial.scala
│ ├── FunctionWithCallbackParameter_Tutorial.scala
│ ├── FunctionWithImplicitParameters_Tutorial.scala
│ ├── FunctionWithOptionParameters_Tutorial.scala
│ ├── FunctionWithOptionReturnType_Tutorial.scala
│ ├── FunctionWithParameters_Tutorial.scala
│ └── FunctionWithVariableArguments_Tutorial.scala
└── two/
├── tutorial_01/
│ └── VariablesBasics_Tutorial.scala
├── tutorial_02/
│ └── StringInterpolation_Tutorial.scala
├── tutorial_03/
│ └── EscapeCharacter_Tutorial.scala
├── tutorial_04/
│ └── VariablesTypeInference_Tutorial.scala
├── tutorial_05/
│ └── If_Else_Expression_Tutorial.scala
├── tutorial_06/
│ └── ForLoop_Tutorial.scala
├── tutorial_07/
│ └── Range_Tutorial.scala
├── tutorial_08/
│ └── WhileLoop_Tutorial.scala
├── tutorial_09/
│ └── PatternMatching_Tutorial.scala
├── tutorial_10/
│ └── Tuples_Tutorial.scala
├── tutorial_11/
│ └── Option_Tutorial.scala
├── tutorial_12/
│ └── TypeHierarchy_Tutorial.scala
└── tutorial_13/
└── Enumeration_Tutorial.scala
Condensed preview — 173 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (452K chars).
[
{
"path": ".gitignore",
"chars": 191,
"preview": "*.class\n*.log\n\n# sbt specific\n.cache\n.history\n.lib/\ndist/*\ntarget/\nlib_managed/\nsrc_managed/\nproject/boot/\nproject/plugi"
},
{
"path": "LICENSE",
"chars": 584,
"preview": "Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n\nLicensed under the Apache License, Version 2.0 (the \"License\")"
},
{
"path": "README.md",
"chars": 54439,
"preview": "# Source Code For Scala Tutorials From www.allaboutscala.com\n## Introduction\nThe Scala programming language is rapidly g"
},
{
"path": "source-code/allaboutscala/.gitignore",
"chars": 191,
"preview": "*.class\n*.log\n\n# sbt specific\n.cache\n.history\n.lib/\ndist/*\ntarget/\nlib_managed/\nsrc_managed/\nproject/boot/\nproject/plugi"
},
{
"path": "source-code/allaboutscala/build.sbt",
"chars": 399,
"preview": "name := \"allaboutscala\"\n\nversion := \"1.0\"\n\nscalaVersion := \"2.12.4\"\n\nval scalaLogging = \"com.typesafe.scala-logging\" %% "
},
{
"path": "source-code/allaboutscala/project/build.properties",
"chars": 20,
"preview": "sbt.version = 0.13.8"
},
{
"path": "source-code/allaboutscala/project/plugins.sbt",
"chars": 22,
"preview": "logLevel := Level.Warn"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Aggregate_Tutorial.scala",
"chars": 2493,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Collect_Tutorial.scala",
"chars": 1694,
"preview": "package com.allaboutscala.chapter.eight\n\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How "
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Diff_Tutorial.scala",
"chars": 2121,
"preview": "package com.allaboutscala.chapter.eight\n\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How "
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/DropWhile_Tutorial.scala",
"chars": 1824,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Drop_Tutorial.scala",
"chars": 1460,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Exists_Tutorial.scala",
"chars": 2296,
"preview": "package com.allaboutscala.chapter.eight\n\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How "
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/FilterFilterNot_Tutorial.scala",
"chars": 1785,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Find_Tutorial.scala",
"chars": 1971,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/FlatMap_Tutorial.scala",
"chars": 1951,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Flatten_Tutorial.scala",
"chars": 2041,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/FoldLeft_Tutorial.scala",
"chars": 2015,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/FoldRight_Tutorial.scala",
"chars": 2028,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Fold_Tutorial.scala",
"chars": 1991,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Foreach_Tutorial.scala",
"chars": 1899,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/GroupBy_Tutorial.scala",
"chars": 2045,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Head_Tutorial.scala",
"chars": 1842,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Intersect_Tutorial.scala",
"chars": 1894,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/IsEmpty_Tutorial.scala",
"chars": 1609,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Last_Tutorial.scala",
"chars": 1846,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Map_Tutorial.scala",
"chars": 2174,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/MaxBy_Tutorial.scala",
"chars": 2004,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Max_Tutorial.scala",
"chars": 1630,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/MinBy_Tutorial.scala",
"chars": 1996,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Min_Tutorial.scala",
"chars": 1645,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/MkString_Tutorial.scala",
"chars": 1696,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/NonEmpty_Tutorial.scala",
"chars": 1639,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Par_Tutorial.scala",
"chars": 1604,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Partition_Tutorial.scala",
"chars": 2086,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ReduceLeft_Tutorial.scala",
"chars": 3019,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ReduceRight_Tutorial.scala",
"chars": 3042,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Reduce_Tutorial.scala",
"chars": 2941,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ReverseIterator.scala",
"chars": 1571,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Reverse_Tutorial.scala",
"chars": 1494,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ScanLeft_Tutorial.scala",
"chars": 1964,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ScanRight_Tutorial.scala",
"chars": 2033,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Scan_Tutorial.scala",
"chars": 1931,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Size_Tutorial.scala",
"chars": 1477,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Slice_Tutorial.scala",
"chars": 1680,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/SortBy_Tutorial.scala",
"chars": 1546,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/SortWith_Tutorial.scala",
"chars": 2388,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Sorted_Tutorial.scala",
"chars": 1669,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Tail_Tutorial.scala",
"chars": 1671,
"preview": "package com.allaboutscala.chapter.eight\n\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How "
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/TakeRight_Tutorial.scala",
"chars": 1517,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/TakeWhile_Tutorial.scala",
"chars": 1812,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Take_Tutorial.scala",
"chars": 1513,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Transpose_Tutorial.scala",
"chars": 1701,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Union_Tutorial.scala",
"chars": 1779,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Unzip3_Tutorial.scala",
"chars": 1550,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Unzip_Tutorial.scala",
"chars": 1849,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ViewTutorial.scala",
"chars": 1528,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/WithFilter_Tutorial.scala",
"chars": 1371,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ZipWIthIndex.scala",
"chars": 1496,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Zip_Tutorial.scala",
"chars": 1800,
"preview": "package com.allaboutscala.chapter.eight\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/five/ExtendMultipleTraits.scala",
"chars": 2941,
"preview": "package com.allaboutscala.chapter.five\n\n/**\n * /**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Lear"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/five/ExtendTrait_Tutorial.scala",
"chars": 2732,
"preview": "package com.allaboutscala.chapter.five\n\n/**\n * /**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Lear"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/five/TraitDependencyInjectionPartTwo_Tutorial.scala",
"chars": 4484,
"preview": "package com.allaboutscala.chapter.five\n\n/**\n * /**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Lear"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/five/TraitDependencyInjection_Tutorial.scala",
"chars": 4342,
"preview": "package com.allaboutscala.chapter.five\n\n/**\n * /**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Lear"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/five/TraitFactory_Tutorial.scala",
"chars": 2154,
"preview": "package com.allaboutscala.chapter.five\n\n/**\n * /**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Trai"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/five/TraitWithTypes_Tutorial.scala",
"chars": 2731,
"preview": "package com.allaboutscala.chapter.five\n\n/**\n * /**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Lear"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/CaseClassInheritance_Tutorial.scala",
"chars": 1807,
"preview": "package com.allaboutscala.chapter.four\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/CaseClass_Tutorial.scala",
"chars": 2538,
"preview": "package com.allaboutscala.chapter.four\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/CompanionObjectAsFactory_Tutorial.scala",
"chars": 2208,
"preview": "package com.allaboutscala.chapter.four\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/CompanionObjectFields_Tutorial.scala",
"chars": 1955,
"preview": "package com.allaboutscala.chapter.four\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/CompanionObject_Tutorial.scala",
"chars": 1710,
"preview": "package com.allaboutscala.chapter.four\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/ContraVariance_Tutorial.scala",
"chars": 2857,
"preview": "package com.allaboutscala.chapter.four\n\nimport com.allaboutscala.chapter.four.Covariance_Tutorial.{GlazedDonut, VanillaD"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/Covariance_Tutorial.scala",
"chars": 2721,
"preview": "package com.allaboutscala.chapter.four\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/ExtendClass_Tutorial.scala",
"chars": 1983,
"preview": "package com.allaboutscala.chapter.four\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/ImplicitClass_Tutorial.scala",
"chars": 1945,
"preview": "package com.allaboutscala.chapter.four\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/PackageObject_Tutorial.scala",
"chars": 1759,
"preview": "package com.allaboutscala.chapter.four\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/SimpleClass_Tutorial.scala",
"chars": 1835,
"preview": "package com.allaboutscala.chapter.four\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/SingletonObject_Tutorial.scala",
"chars": 1811,
"preview": "package com.allaboutscala.chapter.four\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/TypeAlias_Tutorial.scala",
"chars": 2994,
"preview": "package com.allaboutscala.chapter.four\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/TypeClass_Tutorial.scala",
"chars": 2197,
"preview": "package com.allaboutscala.chapter.four\n\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/package.scala",
"chars": 1458,
"preview": "package com.allaboutscala.chapter\n\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To Use"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_01_Function_With_Future_Return_Type.scala",
"chars": 1555,
"preview": "package com.allaboutscala.chapter.nine\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Method with "
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_02_Non_Blocking_Future_Result.scala",
"chars": 1595,
"preview": "package com.allaboutscala.chapter.nine\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Non blocking"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_03_Chain_Futures_FlatMap.scala",
"chars": 1796,
"preview": "package com.allaboutscala.chapter.nine\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Chain future"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_04_Chain_Futures_For_Comprehension.scala",
"chars": 1733,
"preview": "package com.allaboutscala.chapter.nine\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Chain future"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_05_Future_Option_With_For_Comprehension.scala",
"chars": 1847,
"preview": "package com.allaboutscala.chapter.nine\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Future optio"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_06_Future_Option_Map.scala",
"chars": 1528,
"preview": "package com.allaboutscala.chapter.nine\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Future optio"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_07_Composing_Futures.scala",
"chars": 1962,
"preview": "package com.allaboutscala.chapter.nine\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Composing fu"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_08_Future_Sequence.scala",
"chars": 2389,
"preview": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Failure, Success}\n\n/**\n * Created by Nadim Bahadoor on 28/06"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_09_Future_Traverse.scala",
"chars": 1931,
"preview": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Failure, Success}\n\n/**\n * Created by Nadim Bahadoor on 28/06"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_10_Future_FoldLeft.scala",
"chars": 1947,
"preview": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Success, Failure}\n\n\n/**\n * Created by Nadim Bahadoor on 28/0"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_11_Future_Reduce.scala",
"chars": 1966,
"preview": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Failure, Success}\n\n/**\n * Created by Nadim Bahadoor on 28/06"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_12_Future_FirstCompletedOf.scala",
"chars": 1955,
"preview": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Success, Failure}\n\n/**\n * Created by Nadim Bahadoor on 28/06"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_13_Future_Zip.scala",
"chars": 1819,
"preview": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Success, Failure}\n\n/**\n * Created by Nadim Bahadoor on 28/06"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_14_Future_ZipWith.scala",
"chars": 2063,
"preview": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Success, Failure}\n\n\n/**\n * Created by Nadim Bahadoor on 28/0"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_15_Future_AndThen.scala",
"chars": 1478,
"preview": "package com.allaboutscala.chapter.nine\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Future andTh"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_16_Future_Configure_ThreadPool.scala",
"chars": 1934,
"preview": "package com.allaboutscala.chapter.nine\n\nimport java.util.concurrent.Executors\n\nimport scala.util.{Success, Failure}\n\n\n/*"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_17_Future_Recover.scala",
"chars": 1985,
"preview": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Failure, Success}\n\n/**\n * Created by Nadim Bahadoor on 28/06"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_18_Future_RecoverWith.scala",
"chars": 2025,
"preview": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Success, Failure}\n\n\n/**\n * Created by Nadim Bahadoor on 28/0"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_19_Future_FallbackTo.scala",
"chars": 1942,
"preview": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Failure, Success}\n\n\n/**\n * Created by Nadim Bahadoor on 28/0"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_20_Future_Promise.scala",
"chars": 2415,
"preview": "package com.allaboutscala.chapter.nine\n\nimport scala.concurrent.Promise\nimport scala.util.{Success, Try, Failure}\n\n\n/**\n"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/one/tutorial_04/HelloWorld.scala",
"chars": 1017,
"preview": "package com.allaboutscala.chapter.one.tutorial_04\n\n/**\n * Created by Nadim Bahadoor on 01/05/2016.\n *\n * Tutorial: Yo"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/one/tutorial_05/HelloWorldMain.scala",
"chars": 1079,
"preview": "package com.allaboutscala.chapter.one.tutorial_05\n\n/**\n * Created by Nadim Bahadoor on 02/05/2016.\n *\n * Tutorial: Wh"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/one/tutorial_06/HelloWorldWithArguments.scala",
"chars": 1148,
"preview": "package com.allaboutscala.chapter.one.tutorial_06\n\n/**\n * Created by Nadim Bahadoor on 03/05/2016.\n *\n * Tutorial: In"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/one/tutorial_07/HelloWorldWithArgumentsDebug.scala",
"chars": 1182,
"preview": "package com.allaboutscala.chapter.one.tutorial_07\n\n\n/**\n * Created by Nadim Bahadoor on 05/05/2016.\n *\n * Tutorial: I"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/one/tutorial_10/HelloWorldWithScalaLogging.scala",
"chars": 1133,
"preview": "package com.allaboutscala.chapter.one.tutorial_10\n\nimport com.typesafe.scalalogging.LazyLogging\n\n/**\n * Created by Nadi"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableArrayBuffer_Tutorial.scala",
"chars": 2534,
"preview": "package com.allaboutscala.chapter.seven\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableArrayStack_Tutorial.scala",
"chars": 2424,
"preview": "package com.allaboutscala.chapter.seven\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableArray_Tutorial.scala",
"chars": 5006,
"preview": "package com.allaboutscala.chapter.seven\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableBitSet_Tutorial.scala",
"chars": 2340,
"preview": "package com.allaboutscala.chapter.seven\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableHashMap_Tutorial.scala",
"chars": 2334,
"preview": "package com.allaboutscala.chapter.seven\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableHashSet_Tutorial.scala",
"chars": 2642,
"preview": "package com.allaboutscala.chapter.seven\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableLinkedHashMap_Tutorial.scala",
"chars": 2597,
"preview": "package com.allaboutscala.chapter.seven\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableLinkedHashSet_Tutorial.scala",
"chars": 3285,
"preview": "package com.allaboutscala.chapter.seven\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableListBuffer_Tutorial.scala",
"chars": 2409,
"preview": "package com.allaboutscala.chapter.seven\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableListMap_Tutorial.scala",
"chars": 2370,
"preview": "package com.allaboutscala.chapter.seven\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableMap_Tutorial.scala",
"chars": 2186,
"preview": "package com.allaboutscala.chapter.seven\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableQueue_Tutorial.scala",
"chars": 2135,
"preview": "package com.allaboutscala.chapter.seven\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableSet_Tutorial.scala",
"chars": 2479,
"preview": "package com.allaboutscala.chapter.seven\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableSortedSet_Tutorial.scala",
"chars": 3278,
"preview": "package com.allaboutscala.chapter.seven\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableTreeSet_Tutorial.scala",
"chars": 3176,
"preview": "package com.allaboutscala.chapter.seven\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/PriorityQueue_Tutorial.scala",
"chars": 2765,
"preview": "package com.allaboutscala.chapter.seven\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableBitSet_Tutorial.scala",
"chars": 2448,
"preview": "package com.allaboutscala.chapter.six\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To "
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableHashMap_Tutorial.scala",
"chars": 2464,
"preview": "package com.allaboutscala.chapter.six\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To "
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableHashSet_Tutorial.scala",
"chars": 2800,
"preview": "package com.allaboutscala.chapter.six\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To "
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableListMap_Tutorial.scala",
"chars": 2301,
"preview": "package com.allaboutscala.chapter.six\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To "
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableListSet_Tutorial.scala",
"chars": 2315,
"preview": "package com.allaboutscala.chapter.six\n\nimport scala.collection.immutable.ListSet\n\n/**\n * Created by Nadim Bahadoor on 2"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableList_Tutorial.scala",
"chars": 2324,
"preview": "package com.allaboutscala.chapter.six\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To "
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableMap_Tutorial.scala",
"chars": 2213,
"preview": "package com.allaboutscala.chapter.six\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To "
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableQueue_Tutorial.scala",
"chars": 2537,
"preview": "package com.allaboutscala.chapter.six\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To "
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableSequence_Tutorial.scala",
"chars": 1940,
"preview": "package com.allaboutscala.chapter.six\n\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableSet_Tutorial.scala",
"chars": 2483,
"preview": "package com.allaboutscala.chapter.six\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To "
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableSortedSet_Tutorial.scala",
"chars": 3435,
"preview": "package com.allaboutscala.chapter.six\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To "
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableStack_Tutorial.scala",
"chars": 2405,
"preview": "package com.allaboutscala.chapter.six\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To "
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableStream_Tutorial.scala",
"chars": 2373,
"preview": "package com.allaboutscala.chapter.six\n\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableTreeMap_Tutorial.scala",
"chars": 3019,
"preview": "package com.allaboutscala.chapter.six\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To "
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableTreeSet_Tutorial.scala",
"chars": 3317,
"preview": "package com.allaboutscala.chapter.six\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To "
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableVector_Tutorial.scala",
"chars": 2220,
"preview": "package com.allaboutscala.chapter.six\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How To "
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/CreateAndUseFunction_Tutorial.scala",
"chars": 1891,
"preview": "package com.allaboutscala.chapter.three\n\n/**\n * Created by Nadim Bahadoor on 26/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionAsValues_Tutorial.scala",
"chars": 2288,
"preview": "package com.allaboutscala.chapter.three\n\nimport scala.util.Random\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionByName_Tutorial.scala",
"chars": 2604,
"preview": "package com.allaboutscala.chapter.three\n\nimport scala.util.Random\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionCompositionAndThen_Tutorial.scala",
"chars": 1928,
"preview": "package com.allaboutscala.chapter.three\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn Funct"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionCompositionCompose_Tutorial.scala",
"chars": 1928,
"preview": "package com.allaboutscala.chapter.three\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn Funct"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionCurriedParameterGroups_Tutorial.scala",
"chars": 1833,
"preview": "package com.allaboutscala.chapter.three\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionDefinedAsSymbols_Tutorial.scala",
"chars": 2084,
"preview": "package com.allaboutscala.chapter.three\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionHigherOrderAsParameters_Tutorial.scala",
"chars": 2482,
"preview": "package com.allaboutscala.chapter.three\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionRecursiveTailCall_Tutorial.scala",
"chars": 2801,
"preview": "package com.allaboutscala.chapter.three\n\nimport scala.util.control.TailCalls._\n\n\n/**\n * Created by Nadim Bahadoor on 28"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionRecursive_Tutorial.scala",
"chars": 1855,
"preview": "package com.allaboutscala.chapter.three\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionTrampoline_Tutorial.scala",
"chars": 2814,
"preview": "package com.allaboutscala.chapter.three\n\nimport scala.util.control.TailCalls._\n\n/**\n * Created by Nadim Bahadoor on 28/"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWhichIsImplicit_Tutorial.scala",
"chars": 1890,
"preview": "package com.allaboutscala.chapter.three\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWhichIsNested.scala",
"chars": 2402,
"preview": "package com.allaboutscala.chapter.three\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWhichIsPartial_Tutorial.scala",
"chars": 2268,
"preview": "package com.allaboutscala.chapter.three\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWhichIsPolymorphicWithGenericReturnType_Tutorial.scala",
"chars": 2625,
"preview": "package com.allaboutscala.chapter.three\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWhichIsTyped_Tutorial.scala",
"chars": 2079,
"preview": "package com.allaboutscala.chapter.three\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWithCallbackParameter_Tutorial.scala",
"chars": 2337,
"preview": "package com.allaboutscala.chapter.three\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWithImplicitParameters_Tutorial.scala",
"chars": 2482,
"preview": "package com.allaboutscala.chapter.three\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWithOptionParameters_Tutorial.scala",
"chars": 2786,
"preview": "package com.allaboutscala.chapter.three\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWithOptionReturnType_Tutorial.scala",
"chars": 2843,
"preview": "package com.allaboutscala.chapter.three\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWithParameters_Tutorial.scala",
"chars": 2012,
"preview": "package com.allaboutscala.chapter.three\n\n/**\n * Created by Nadim Bahadoor on 26/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWithVariableArguments_Tutorial.scala",
"chars": 1989,
"preview": "package com.allaboutscala.chapter.three\n\n/**\n * Created by Nadim Bahadoor on 28/06/2016.\n *\n * Tutorial: Learn How T"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_01/VariablesBasics_Tutorial.scala",
"chars": 1905,
"preview": "package com.allaboutscala.chapter.two.tutorial_01\n\n/**\n * Created by Nadim Bahadoor on 07/06/2016.\n *\n * Tutorial: Sc"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_02/StringInterpolation_Tutorial.scala",
"chars": 2143,
"preview": "package com.allaboutscala.chapter.two.tutorial_02\n\n/**\n * Created by Nadim Bahadoor on 08/06/2016.\n *\n * Tutorial: Sc"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_03/EscapeCharacter_Tutorial.scala",
"chars": 2140,
"preview": "package com.allaboutscala.chapter.two.tutorial_03\n\n/**\n * Created by Nadim Bahadoor on 09/06/2016.\n *\n * Tutorial: Sc"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_04/VariablesTypeInference_Tutorial.scala",
"chars": 1817,
"preview": "package com.allaboutscala.chapter.two.tutorial_04\n\n/**\n * Created by Nadim Bahadoor on 10/06/2016.\n *\n * Tutorial: An"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_05/If_Else_Expression_Tutorial.scala",
"chars": 2093,
"preview": "package com.allaboutscala.chapter.two.tutorial_05\n\n/**\n * Created by Nadim Bahadoor on 13/06/2016.\n *\n * Tutorial: Ho"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_06/ForLoop_Tutorial.scala",
"chars": 2350,
"preview": "package com.allaboutscala.chapter.two.tutorial_06\n\n/**\n * Created by Nadim Bahadoor on 14/06/2016.\n *\n * Tutorial: Le"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_07/Range_Tutorial.scala",
"chars": 2520,
"preview": "package com.allaboutscala.chapter.two.tutorial_07\n\n/**\n * Created by Nadim Bahadoor on 15/06/2016.\n *\n * Tutorial: Le"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_08/WhileLoop_Tutorial.scala",
"chars": 1449,
"preview": "package com.allaboutscala.chapter.two.tutorial_08\n\n/**\n * Created by Nadim Bahadoor on 16/06/2016.\n *\n * Tutorial: Le"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_09/PatternMatching_Tutorial.scala",
"chars": 2773,
"preview": "package com.allaboutscala.chapter.two.tutorial_09\n\n/**\n * Created by Nadim Bahadoor on 17/06/2016.\n *\n * Tutorial: L"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_10/Tuples_Tutorial.scala",
"chars": 2695,
"preview": "package com.allaboutscala.chapter.two.tutorial_10\n\n/**\n * Created by Nadim Bahadoor on 18/06/2016.\n *\n * Tutorial: L"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_11/Option_Tutorial.scala",
"chars": 1778,
"preview": "package com.allaboutscala.chapter.two.tutorial_11\n\n/**\n * Created by Nadim Bahadoor on 20/06/2016.\n *\n * Tutorial: Le"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_12/TypeHierarchy_Tutorial.scala",
"chars": 1450,
"preview": "package com.allaboutscala.chapter.two.tutorial_12\n\n/**\n * Created by Nadim Bahadoor on 22/06/2016.\n *\n * Tutorial: L"
},
{
"path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_13/Enumeration_Tutorial.scala",
"chars": 2243,
"preview": "package com.allaboutscala.chapter.two.tutorial_13\n\n/**\n * Created by Nadim Bahadoor on 23/06/2016.\n *\n * Tutorial: L"
}
]
About this extraction
This page contains the full source code of the nadimbahadoor/allaboutscala GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 173 files (402.5 KB), approximately 116.9k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.