[
  {
    "path": ".gitignore",
    "content": "*.class\n*.log\n\n# sbt specific\n.cache\n.history\n.lib/\ndist/*\ntarget/\nlib_managed/\nsrc_managed/\nproject/boot/\nproject/plugins/project/\n\n# Scala-IDE specific\n.scala_dependencies\n.worksheet\n.idea\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not\nuse this file except in compliance with the License. You may obtain a copy of\nthe License at\n\n    [http://www.apache.org/licenses/LICENSE-2.0]\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\nWARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\nLicense for the specific language governing permissions and limitations under\nthe License.\n"
  },
  {
    "path": "README.md",
    "content": "# Source Code For Scala Tutorials From www.allaboutscala.com\n## Introduction\nThe Scala programming language is rapidly growing in popularity! Sadly, most of the online tutorials do not provide a step-by-step guide :(\n \nAt www.allaboutscala.com, we provide a complete beginner's tutorial to help you learn Scala in **small**, **simple** and **easy steps**.\n\n- Tutorials are organized such that they allow you to **learn gradually**.\n- Tutorials are written by taking into account the **complete beginner**.\n- Tutorials will make you proficient with the same professional **tools used by the Scala experts**.\n\n## Get Our Books\n### Scala For Beginners\nThis 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.\n\nYou can buy the book at https://leanpub.com/scalaforbeginners/\n\n\n## Our Online Tutorials\n### Scala Introduction: A general overview of Scala\n- [1: Introduction](http://allaboutscala.com/tutorials/scala-introduction/)\n- [2: What is Scala programming language](http://allaboutscala.com/tutorials/scala-introduction/learn-scala-programming-language/)\n- [3: Scala functional programming features and more!](http://allaboutscala.com/tutorials/scala-introduction/scala-functional-programming-features/)\n\n### Chapter 1: Getting familiar with the IntelliJ IDEA\n- [1: Introduction](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/)\n- [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/)\n- [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/) \n- [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/)\n- [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/)\n- [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/)\n- [7: IntelliJ Run Configuration – Running Your Scala application](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/intellij-run-configuration-scala-application/)\n- [8: IntelliJ Debug Configuration – Debugging Your Scala Application](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/intellij-debug-configuration-scala-application/)\n- [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/)\n- [10: IntelliJ Project Structure – Scala Project Classpath](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/intellij-project-structure-scala-project-classpath/)\n- [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/)\n- [12: IntelliJ Import Dependencies – SBT Dependencies And Maven](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/intellij-import-dependencies-sbt-maven/)\n- [13: IntelliJ Manage Configurations – Settings, Preferences](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/intellij-manage-configurations-settings-preferences-win-mac/)\n- [14: IntelliJ Keyboard Shortcuts – Navigation Shortcuts](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/intellij-keyboard-shortcuts-navigation)\n- [15: IntelliJ Keyboard Shortcuts – Search Shortcuts](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/intellij-keyboard-shortcuts-search/)\n- [16: IntelliJ Keyboard Shortcuts – Compile, Debug, Run](http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/intellij-keyboard-shortcuts-compile-debug-run/)\n \n### Chapter 2: Learning the basic foundation of Scala\n- [1: Introduction](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/)\n- [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/)\n- [3: Scala String Interpolation – Print And Format Variables](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-string-interpolation-print-format-variables/)\n- [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/)\n- [5: An Overview Of Scala Type Inference](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-overview-scala-type-inference/)\n- [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/)\n- [7: Learn How To Use For Comprehension](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-learn-use-for-comprehension/)\n- [8: Learn How To Use Range](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-learn-use-range-inclusive-exclusive/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [14: Learn How To Create And Use Enumerations](http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/learn-to-create-use-enumerations/)\n\n### Chapter 3: Thinking In Terms Of Functions\n- [1: Introduction](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [7: Learn How To Create Implicit Function](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-implicit-function/)\n- [8: Learn How To Create Typed Function](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-typed-function/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [17: Learn Function Composition Using AndThen](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-function-composition-andthen/)\n- [18: Learn Function Composition Using Compose](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-function-composition-compose/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [23: Learn How To Create Nested Function](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-nested-function/)\n \n\n### Chapter 4: Think you know Object Oriented using classes?\n- [1: Introduction](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [10: Learn How To Use Package Object](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-package-object/)\n- [11: Learn How To Extend Class - Class Inheritance](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-extend-class/)\n- [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/)\n- [13: Learn How To Create Type Class](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-type-class/)\n- [14: Learn How To Create Covariance Type Class](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-variance-covariance/)\n- [15: Learn How To Create Contra-Variance Type Class](http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-variance-contra-variance/)\n\n\n### Chapter 5: Dependency Injection reinvented using traits\n- [1: Introduction](http://allaboutscala.com/tutorials/chapter-5-traits/)\n- [2: Learn How To Create And Extend Trait In Scala](http://allaboutscala.com/tutorials/chapter-5-traits/scala-extend-trait/)\n- [3: Learn How To Create Trait With Type Parameters](http://allaboutscala.com/tutorials/chapter-5-traits/scala-trait-type-parameters/)\n- [4: Learn How To Extend Multiple Traits](http://allaboutscala.com/tutorials/chapter-5-traits/scala-extend-multiple-traits/)\n- [5: Learn How To Use Traits For Dependency Injection](http://allaboutscala.com/tutorials/chapter-5-traits/scala-traits-depedency-injection/)\n- [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/)\n- [7: Traits, Companion Object, Factory Pattern](http://allaboutscala.com/tutorials/chapter-5-traits/scala-traits-companion-object-factory-pattern/)\n\n\n### Chapter 6: Immutable Collection\n- [1: Introduction](http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n\n\n### Chapter 7: Mutable Collection\n- [1: Introduction](http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n- [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/)\n\n### Chapter 8: Collection Functions\n- [1: Introduction](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/)\n- [2: Learn How To Use Aggregate Function](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-aggregate-function/)\n- [3: Learn How To Use Collect Function](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-collect-function/)\n- [4: Learn How To Use Diff Function](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-diff-function/)\n- [5: Learn How To Use Drop Function](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-drop-function/)\n- [6: Learn How To Use DropWhile Function](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-dropwhile-function/)\n- [7: Learn How To Use Exists Function](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-exists-function/)\n- [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/)\n- [9: Learn How To Use Find Function](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-find-function/)\n- [10: Learn How To Use FlatMap Function](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-flatmap-function/)\n- [11: Learn How To Use Flatten Function](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-flatten-function-example/)\n- [12: Learn How To Use Fold Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-fold-example/)\n- [13: Learn How To Use FoldLeft Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-foldleft-example/)\n- [14: Learn How To Use FoldRight Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-foldright-example/)\n- [15: Learn How To Use Foreach Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-foreach-example/)\n- [16: Learn How To Use GroupBy Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-groupby-example/)\n- [17: Learn How To Use Head Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-head-example/)\n- [18: Learn How To Use IsEmpty Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-isempty-example/)\n- [19: Learn How To Use Intersect Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-intersect-example/)\n- [20: Learn How To Use Last Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-last-example/)\n- [21: Learn How To Use Map Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-map-example/)\n- [22: Learn How To Use Max Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-max-example/)\n- [23: Learn How To Use MaxBy Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-maxby-example/)\n- [24: Learn How To Use Min Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-min-example/)\n- [25: Learn How To Use MinBy Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-minby-example/)\n- [26: Learn How To Use MkString Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-mkstring-example/)\n- [27: Learn How To Use NonEmpty Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-nonempty-example/)\n- [28: Learn How To Use Par Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-par-example/)\n- [29: Learn How To Use Partition Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-partition-example/)\n- [30: Learn How To Use Reduce Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reduce-example/)\n- [31: Learn How To Use ReduceLeft Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reduceleft-example/)\n- [32: Learn How To Use ReduceRight Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reduceright-example/)\n- [33: Learn How To Use Reverse Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reverse-example/)\n- [34: Learn How To Use ReverseIterator Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reverseiterator-example/)\n- [35: Learn How To Use Scan Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-scan-example/)\n- [36: Learn How To Use ScanLeft Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-scanleft-example/)\n- [37: Learn How To Use ScanRight Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-scanright-example/)\n- [38: Learn How To Use Size Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-size-example/)\n- [39: Learn How To Use Slice Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-slice-example/)\n- [40: Learn How To Use SortBy Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-sortby-example/)\n- [41: Learn How To Use Sorted Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-sorted-example/)\n- [42: Learn How To Use SortWith Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-sortwith-example/)\n- [43: Learn How To Use Tail Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-tail-example/)\n- [44: Learn How To Use Take Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-take-example/)\n- [45: Learn How To Use TakeRight Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-takeright-example/)\n- [46: Learn How To Use TakeWhile Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-takewhile-example/)\n- [47: Learn How To Use Transpose Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-transpose-example/)\n- [48: Learn How To Use Union Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-union-example/)\n- [49: Learn How To Use Unzip Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-unzip-example/)\n- [50: Learn How To Use Unzip3 Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-unzip3-example/)\n- [51: Learn How To Use View Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-view-example/)\n- [52: Learn How To Use WithFilter Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-withfilter-example/)\n- [53: Learn How To Use Zip Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-zip-example/)\n- [54: Learn How To Use ZipWithIndex Function With Examples](http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-zipwithindex-example/)\n\n### Chapter 9: Futures\n- [1: Method with future as return type](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#method-future-return-type)\n- [2: Non blocking future result](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#non-blocking-future-result)\n- [3: Chain futures using flatMap](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#chain-futures-using-flatmap)\n- [4: Chain futures using for comprehension](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#chain-futures-using-for-comprehension)\n- [5: Future option with for comprehension](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-option-with-for-comprehension)\n- [6: Future option with map](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-option-with-map)\n- [7: Composing futures](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#composing-futures)\n- [8: Future sequence](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-sequence)\n- [9: Future traverse](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-traverse)\n- [10: Future foldLeft](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-foldLeft)\n- [11: Future reduceLeft](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-reduceLeft)\n- [12: Future firstCompletedOf](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-firstCompletedOf)\n- [13: Future zip](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-zip)\n- [14: Future zipWith](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-zipWith)\n- [15: Future andThen](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-andThen)\n- [16: Future configure threadpool](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-configure-threadpool)\n- [17: Future recover](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-recover)\n- [18: Future recoverWith](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-recoverWith)\n- [19: Future fallbackTo](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-fallbackTo)\n- [20: Future promise](http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-promise)\n\n\n### Chapter 10: Cheatsheet and Scala Test\n### ScalaTest\n- [Introduction](http://allaboutscala.com/scala-cheatsheet/#scalatest-introduction)\n- [Add ScalaTest as dependency to build.sbt](http://allaboutscala.com/scala-cheatsheet/#add-scalatest-dependency-build.sbt)\n- [Create a test class using FlatSpec and Matchers](http://allaboutscala.com/scala-cheatsheet/#test-class-flatspec-matchers)\n- [Equality Test](http://allaboutscala.com/scala-cheatsheet/#scalatest-equality)\n- [Length Test](http://allaboutscala.com/scala-cheatsheet/#scalatest-length)\n- [Boolean Test](http://allaboutscala.com/scala-cheatsheet/#scalatest-boolean)\n- [Collection Test](http://allaboutscala.com/scala-cheatsheet/#scalatest-collection)\n- [Type Test](http://allaboutscala.com/scala-cheatsheet/#scalatest-type)\n- [Exception Test](http://allaboutscala.com/scala-cheatsheet/#scalatest-exception)\n- [Private Method Test](http://allaboutscala.com/scala-cheatsheet/#scalatest-private-method)\n- [Future Method Test](http://allaboutscala.com/scala-cheatsheet/#scalatest-future)\n\n### Collection\n- [Convert Java collection](http://allaboutscala.com/scala-cheatsheet/#convert-java-collection-to-scala)\n\n### General\n- [Add line break](http://allaboutscala.com/scala-cheatsheet/#line-separator)\n- [Convert multi-line string into single line](http://allaboutscala.com/scala-cheatsheet/#multi-line-to-single-line)\n- [Check value of an Option](http://allaboutscala.com/scala-cheatsheet/#check-option-value)\n- [Read file content as a String](http://allaboutscala.com/scala-cheatsheet/#read-file)\n- [Create enum using sealed trait](http://allaboutscala.com/scala-cheatsheet/#create-enum-sealed-trait)\n- [Int division and return float](http://allaboutscala.com/scala-cheatsheet/#int-division-scala)\n\n### Futures\n- [Cannot find an implicit ExecutionContext](http://allaboutscala.com/scala-cheatsheet/#implicit-executioncontext)\n\n\n### Chapter 11: Learn SBT\n#### Install SBT\n- [Install SBT on Windows](http://allaboutscala.com/scala-frameworks/sbt/#install-sb-windows)\n- [Install SBT on Mac](http://allaboutscala.com/scala-frameworks/sbt/#install-sbt-mac)\n\n#### sbt run\n- [Run a Scala main class](http://allaboutscala.com/scala-frameworks/sbt/#sbt-run-main-class)\n\n#### sbt test\n- [Run all tests](http://allaboutscala.com/scala-frameworks/sbt/#sbt-run-test)\n- [Run only one specific test](http://allaboutscala.com/scala-frameworks/sbt/#sbt-run-specific-test)\n- [Run all integration tests](http://allaboutscala.com/scala-frameworks/sbt/#sbt-run-it-test)\n- [Run a specific integration test](http://allaboutscala.com/scala-frameworks/sbt/#sbt-run-specific-it-test)\n- [Run one method in a test class](http://allaboutscala.com/scala-frameworks/sbt/#sbt-run-specific-test-and-test-method)\n\n#### sbt debugging\n- [Analyze stacktrace in IntelliJ](http://allaboutscala.com/scala-frameworks/sbt/#sbt-debug-stacktrace-intellij)\n\n#### sbt resources\n- [Show unmanaged classpaths](http://allaboutscala.com/scala-frameworks/sbt/#sbt-show-unmanaged-classpaths)\n- [Show unmanaged resources](http://allaboutscala.com/scala-frameworks/sbt/#sbt-show-unmanaged-resource-directories)\n\n### Chapter 12: Learn Apache Spark 2\n### Chapter 12 - Part 1\n#### Project Setup\n- [StackOverflow dataset](http://allaboutscala.com/big-data/spark/#stackoverflow-dataset)\n- [Add Apache Spark 2.0 SBT dependencies](http://allaboutscala.com/big-data/spark/#spark-sbt-dependencies)\n- [Bootstrap a SparkSession](http://allaboutscala.com/big-data/spark/#bootstrap-sparksession)\n\n#### DataFrame SQL Query\n- [DataFrame Introduction](http://allaboutscala.com/big-data/spark/#dataframe-introduction)\n- [Create a DataFrame from reading a CSV file](http://allaboutscala.com/big-data/spark/#create-dataframe-read-csv)\n- [DataFrame schema](http://allaboutscala.com/big-data/spark/#print-dataframe-schema)\n- [Select columns from a dataframe](http://allaboutscala.com/big-data/spark/#dataframe-select-columns)\n- [Filter by column value of a dataframe](http://allaboutscala.com/big-data/spark/#filter-column-dataframe)\n- [Count rows of a dataframe](http://allaboutscala.com/big-data/spark/#dataframe-count-rows)\n- [SQL like query](http://allaboutscala.com/big-data/spark/#dataframe-sql-like-query)\n- [Multiple filter chaining](http://allaboutscala.com/big-data/spark/#dataframe-multiple-filter-chains)\n- [SQL IN clause](http://allaboutscala.com/big-data/spark/#dataframe-sql-in-clause)\n- [SQL Group By](http://allaboutscala.com/big-data/spark/#dataframe-sql-group-by)\n- [SQL Group By with filter](http://allaboutscala.com/big-data/spark/#dataframe-sql-group-by-count-filter)\n- [SQL order by](http://allaboutscala.com/big-data/spark/#dataframe-order-by)\n- [Cast columns to specific data type](http://allaboutscala.com/big-data/spark/#dataframe-cast-columns-data-type)\n- [Operate on a filtered dataframe](http://allaboutscala.com/big-data/spark/#dataframe-operations)\n- [DataFrame Join](http://allaboutscala.com/big-data/spark/#dataframe-join)\n- [Join and select columns](http://allaboutscala.com/big-data/spark/#dataframe-join-select-columns)\n- [Join on explicit columns](http://allaboutscala.com/big-data/spark/#dataframe-join-explicit-columns)\n- [Inner Join](http://allaboutscala.com/big-data/spark/#dataframe-inner-join)\n- [Left Outer Join](http://allaboutscala.com/big-data/spark/#dataframe-left-outer-join)\n- [Right Outer Join](http://allaboutscala.com/big-data/spark/#dataframe-right-outer-join)\n- [Distinct](http://allaboutscala.com/big-data/spark/#dataframe-distinct)\n\n### Chatper 12 - Part 2\n#### Spark SQL\n- [Spark SQL Introduction](http://allaboutscala.com/big-data/spark/#spark-sql-introduction)\n- [Register temp table from dataframe](http://allaboutscala.com/big-data/spark/#register-temp-table-from-dataframe)\n- [List all tables in Spark's catalog](http://allaboutscala.com/big-data/spark/#list-tables-spark-catalog)\n- [List catalog tables using Spark SQL](http://allaboutscala.com/big-data/spark/#list-catalog-tables-spark-sql)\n- [Select columns](http://allaboutscala.com/big-data/spark/#spark-sql-select-columns)\n- [Filter by column value](http://allaboutscala.com/big-data/spark/#spark-sql-filter-column-value)\n- [Count number of rows](http://allaboutscala.com/big-data/spark/#spark-sql-count-rows)\n- [SQL like](http://allaboutscala.com/big-data/spark/#spark-sql-like)\n- [SQL where with and clause](http://allaboutscala.com/big-data/spark/#spark-sql-where-with-and-clause)\n- [SQL IN clause](http://allaboutscala.com/big-data/spark/#spark-sql-in-clause)\n- [SQL Group By](http://allaboutscala.com/big-data/spark/#spark-sql-group-by)\n- [SQL Group By with having clause](http://allaboutscala.com/big-data/spark/#spark-sql-group-by-having-clause)\n- [SQL Order by](http://allaboutscala.com/big-data/spark/#spark-sql-order-by)\n- [Typed columns, filter and create temp table](http://allaboutscala.com/big-data/spark/#spark-sql-typed-column-filter-temp-table)\n- [SQL Inner Join](http://allaboutscala.com/big-data/spark/#spark-sql-inner-join)\n- [SQL Left Outer Join](http://allaboutscala.com/big-data/spark/#spark-sql-left-outer-join)\n- [SQL Right Outer Join](http://allaboutscala.com/big-data/spark/#spark-sql-right-outer-join)\n- [SQL Distinct](http://allaboutscala.com/big-data/spark/#spark-sql-distinct)\n- [Register User Defined Function (UDF)](http://allaboutscala.com/big-data/spark/#spark-sql-udf)\n\n### Chapter 12 - Part 3\n#### DataFrame Statistics\n- [DataFrame Statistics Introduction](http://allaboutscala.com/big-data/spark/#dataframe-statistics-introduction)\n- [Create DataFrame from CSV](http://allaboutscala.com/big-data/spark/#create-dataframe-csv)\n- [Average](http://allaboutscala.com/big-data/spark/#dataframe-statistics-average)\n- [Maximum](http://allaboutscala.com/big-data/spark/#dataframe-statistics-max)\n- [Minimum](http://allaboutscala.com/big-data/spark/#dataframe-statistics-minimum)\n- [Mean](http://allaboutscala.com/big-data/spark/#dataframe-statistics-mean)\n- [Sum](http://allaboutscala.com/big-data/spark/#dataframe-statistics-sum)\n- [Group by query with statistics](http://allaboutscala.com/big-data/spark/#dataframe-statistics-group-by-query)\n- [DataFrame Statistics using describe() method](http://allaboutscala.com/big-data/spark/#dataframe-statistics-describe-method)\n- [Correlation](http://allaboutscala.com/big-data/spark/#dataframe-statistics-correlation)\n- [Covariance](http://allaboutscala.com/big-data/spark/#dataframe-statistics-covariance)\n- [Frequent Items](http://allaboutscala.com/big-data/spark/#dataframe-statistics-frequent-items)\n- [Crosstab](http://allaboutscala.com/big-data/spark/#dataframe-statistics-crosstab)\n- [Stratified sampling using sampleBy](http://allaboutscala.com/big-data/spark/#dataframe-statistics-sampleby)\n- [Approximate Quantile](http://allaboutscala.com/big-data/spark/#dataframe-statistics-approxquantile)\n- [Bloom Filter](http://allaboutscala.com/big-data/spark/#spark-dataframe-bloom-filter)\n- [Count Min Sketch](http://allaboutscala.com/big-data/spark/#dataframe-statistics-count-min-sketch)\n- [Sampling With Replacement](http://allaboutscala.com/big-data/spark/#dataframe-sampling-with-replacement)\n\n### Chapter 12 - Part 4\n#### DataFrame Operations\n- [DataFrame Operations Introduction](http://allaboutscala.com/big-data/spark/#dataframe-operations-introduction)\n- [Setup DataFrames](http://allaboutscala.com/big-data/spark/#dataframe-operations-setup)\n- [Convert DataFrame row to Scala case class](http://allaboutscala.com/big-data/spark/#dataframe-convert-row-scala-case-class)\n- [DataFrame row to Scala case class using map()](http://allaboutscala.com/big-data/spark/#dataframe-row-scala-case-class-map-method)\n- [Create DataFrame from collection](http://allaboutscala.com/big-data/spark/#create-dataframe-from-collection)\n- [DataFrame Union](http://allaboutscala.com/big-data/spark/#dataframe-union)\n- [DataFrame Intersection](http://allaboutscala.com/big-data/spark/#dataframe-intersection)\n- [Append column to DataFrame using withColumn()](http://allaboutscala.com/big-data/spark/#dataframe-append-column-withcolumn-method)\n\n#### Spark Functions\n- [Create DataFrame from Tuples](http://allaboutscala.com/big-data/spark/#create-dataframe-from-tuples)\n- [Get DataFrame column names](http://allaboutscala.com/big-data/spark/#get-dataframe-column-names)\n- [DataFrame column names and types](http://allaboutscala.com/big-data/spark/#dataframe-column-names-and-types)\n- [Nested Json into DataFrame using explode method](http://allaboutscala.com/big-data/spark/#json-into-dataframe-using-explode-method)\n- [Concatenate DataFrames using join() method](http://allaboutscala.com/big-data/spark/#concatenate-dataframes-using-join)\n- [Search DataFrame column using array_contains() method](http://allaboutscala.com/big-data/spark/#search-dataframe-column-using-array-contains-method)\n- [Check DataFrame column exists](http://allaboutscala.com/big-data/spark/#check-dataframe-column-exists)\n- [Split DataFrame Array column](http://allaboutscala.com/big-data/spark/#split-dataframe-array-column)\n- [Rename DataFrame column](http://allaboutscala.com/big-data/spark/#rename-dataframe-column)\n- [Create DataFrame constant column](http://allaboutscala.com/big-data/spark/#create-dataframe-constant-column)\n- [DataFrame new column with User Defined Function (UDF](http://allaboutscala.com/big-data/spark/#dataframe-new-column-with-udf)\n- [DataFrame first row](http://allaboutscala.com/big-data/spark/#dataframe-first-row)\n- [Format DataFrame column](http://allaboutscala.com/big-data/spark/#format-dataframe-column)\n- [DataFrame column hashing](http://allaboutscala.com/big-data/spark/#dataframe-column-hashing)\n- [DataFrame String functions](http://allaboutscala.com/big-data/spark/#dataframe-string-functions)\n- [DataFrame drop null](http://allaboutscala.com/big-data/spark/#dataframe-drop-null)\n\n### Chapter 13 - Learn Akka\n#### Introduction\n- [What is Akka](http://allaboutscala.com/scala-frameworks/akka/#what-is-akka)\n- [Project setup build.sbt](http://allaboutscala.com/scala-frameworks/akka/#project-setup-build-sbt)\n\n#### Akka Actors\n- [Actor System Introduction](http://allaboutscala.com/scala-frameworks/akka/#actor-system-introduction)\n- [Tell Pattern](http://allaboutscala.com/scala-frameworks/akka/#tell-pattern)\n- [Ask Pattern](http://allaboutscala.com/scala-frameworks/akka/#ask-pattern)\n- [Ask Pattern mapTo](http://allaboutscala.com/scala-frameworks/akka/#ask-pattern-mapto)\n- [Ask Pattern pipeTo](http://allaboutscala.com/scala-frameworks/akka/#ask-pattern-pipeto)\n- [Actor Hierarchy](http://allaboutscala.com/scala-frameworks/akka/#actor-hierarchy)\n- [Actor Lookup](http://allaboutscala.com/scala-frameworks/akka/#actor-lookup)\n- [Child Actors](http://allaboutscala.com/scala-frameworks/akka/#child-actors)\n- [Actor Lifecycle](http://allaboutscala.com/scala-frameworks/akka/#actor-lifecycle)\n- [Actor PoisonPill](http://allaboutscala.com/scala-frameworks/akka/#actor-poisonpill)\n- [Error Kernel Supervision](http://allaboutscala.com/scala-frameworks/akka/#error-kernel-supervision)\n\n#### Akka Routers\n- [RoundRobinPool](http://allaboutscala.com/scala-frameworks/akka/#roundrobinpool-router)\n- [ScatterGatherFirstCompletedPool](http://allaboutscala.com/scala-frameworks/akka/#scattergatherfirstcompletedpool-router)\n- [TailChoppingPool](http://allaboutscala.com/scala-frameworks/akka/#tailchoppingpool-router)\n- [BroadcastPool](http://allaboutscala.com/scala-frameworks/akka/#broadcastpool-router)\n\n#### Akka Dispatchers\n- [Akka Default Dispatcher](http://allaboutscala.com/scala-frameworks/akka/#akka-default-dispatcher)\n- [Akka Lookup Dispatcher](http://allaboutscala.com/scala-frameworks/akka/#akka-lookup-dispatcher)\n- [Fixed Thread Pool Dispatcher](http://allaboutscala.com/scala-frameworks/akka/#fixed-thread-pool-dispatcher)\n- [Resizable Thread Pool Dispatcher](http://allaboutscala.com/scala-frameworks/akka/#resizable-thread-pool)\n- [Pinned Thread Pool Dispatcher](http://allaboutscala.com/scala-frameworks/akka/#pinned-thread-pool-dispatcher)\n\n#### Akka FSM\n- [Actor FSM become()](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-become)\n- [Actor FSM unbecome()](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-unbecome)\n- [Actor FSM protocol](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-protocol)\n- [Actor LoggingFSM](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-loggingfsm)\n- [Actor LoggingFSM Part Two](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-loggingfsm-part-two)\n- [Actor LoggingFSM Part Three](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-loggingfsm-part-three)\n- [Actor LoggingFSM Part Four](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-loggingfsm-part-four)\n- [Actor LoggingFSM Part Five](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-loggingfsm-part-five)\n- [Actor LoggingFSM Part Six](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-loggingfsm-part-six)\n- [Actor FSM Scheduler](http://allaboutscala.com/scala-frameworks/akka/#actor-fsm-scheduler)\n\n#### Akka TestKit\n- [Testing Actor FSM](http://allaboutscala.com/scala-frameworks/akka/#akka-testkit-test-actor-fsm)\n- [Testing Actor](http://allaboutscala.com/scala-frameworks/akka/#akka-testkit-test-actor)\n- [Testing Akka HTTP POST](http://allaboutscala.com/scala-frameworks/akka/#akka-testkit-http-post)\n- [Testing Query Parameter](http://allaboutscala.com/scala-frameworks/akka/#akka-testkit-query-parameter)\n- [Testing Required Query Parameter](http://allaboutscala.com/scala-frameworks/akka/#akka-testkit-required-query-parameter)\n- [Testing Optional Query Parameter](http://allaboutscala.com/scala-frameworks/akka/#akka-testkit-optional-query-parameter)\n- [Testing Typed Query Parameter](http://allaboutscala.com/scala-frameworks/akka/#akka-testkit-typed-query-parameter)\n- [Testing CSV Query Parameter](http://allaboutscala.com/scala-frameworks/akka/#akka-testkit-csv-query-parameter)\n\n#### Akka HTTP\n- [Akka HTTP project setup build.sbt](http://allaboutscala.com/scala-frameworks/akka/#akka-http-project-setup-build-sbt)\n- [Start Akka HTTP Server](http://allaboutscala.com/scala-frameworks/akka/#akka-http-start-server)\n- [HTTP GET plain text](http://allaboutscala.com/scala-frameworks/akka/#akka-http-get-plain-text)\n- [HTTP GET JSON response](http://allaboutscala.com/scala-frameworks/akka/#akka-http-get-json-response)\n- [JSON encoding](http://allaboutscala.com/scala-frameworks/akka/#akka-http-json-encoding)\n- [JSON pretty print](http://allaboutscala.com/scala-frameworks/akka/#akka-http-json-pretty-print)\n- [HTTP POST JSON payload](http://allaboutscala.com/scala-frameworks/akka/#akka-http-post-json)\n- [Could not find implicit value](http://allaboutscala.com/scala-frameworks/akka/#akka-http-could-not-find-implicit-value)\n- [HTTP DELETE restriction](http://allaboutscala.com/scala-frameworks/akka/#akka-http-delete-method-restriction)  \n- [Future onSuccess](http://allaboutscala.com/scala-frameworks/akka/#akka-http-future-onsuccess)\n- [Future onComplete](http://allaboutscala.com/scala-frameworks/akka/#akka-http-future-oncomplete)\n- [Complete with an HttpResponse](http://allaboutscala.com/scala-frameworks/akka/#akka-http-complete-httpresponse)\n- [Try failure using an HttpResponse](http://allaboutscala.com/scala-frameworks/akka/#akka-http-try-failure-httpresponse)\n- [Global rejection handler](http://allaboutscala.com/scala-frameworks/akka/#akka-http-global-rejection-handler)\n- [Global exception handler](http://allaboutscala.com/scala-frameworks/akka/#akka-http-global-exception-handler)\n- [Load HTML from resources](http://allaboutscala.com/scala-frameworks/akka/#akka-http-load-html-resource)\n- [RESTful URLs with segment](http://allaboutscala.com/scala-frameworks/akka/#akka-http-rest-url-segment)\n- [RESTful URLS with regex](http://allaboutscala.com/scala-frameworks/akka/#akka-http-rest-url-regex)\n- [RESTful URLS with multiple segments](http://allaboutscala.com/scala-frameworks/akka/#akka-http-multiple-segments)\n- [Query parameter](http://allaboutscala.com/scala-frameworks/akka/#akka-http-query-parameter)\n- [Optional query parameter](http://allaboutscala.com/scala-frameworks/akka/#akka-http-optional-query-parameter)\n- [Typed query parameters](http://allaboutscala.com/scala-frameworks/akka/#akka-http-typed-query-parameters)\n- [CSV query parameter](http://allaboutscala.com/scala-frameworks/akka/#akka-http-csv-query-parameter)\n- [Query parameter to case class](http://allaboutscala.com/scala-frameworks/akka/#akka-http-query-parameter-to-case-class)\n- [HTTP request headers](http://allaboutscala.com/scala-frameworks/akka/#akka-http-request-headers)\n- [HTTP client GET](http://allaboutscala.com/scala-frameworks/akka/#akka-http-client-get)\n- [Unmarshal HttpResponse to case class](http://allaboutscala.com/scala-frameworks/akka/#akka-http-unmarshal-case-class)\n- [HTTP client POST JSON](http://allaboutscala.com/scala-frameworks/akka/#akka-http-client-post-json)\n\n### Chapter 14 - Learn Cassandra\n#### Introduction\n- [What is Apache Cassandra](http://allaboutscala.com/big-data/cassandra/#introduction)\n- [Install Apache Cassandra](http://allaboutscala.com/big-data/cassandra/#install-apache-cassandra)\n- [Using nodetool](http://allaboutscala.com/big-data/cassandra/#using-nodetool)\n- [cassandra.yaml](http://allaboutscala.com/big-data/cassandra/#cassandra.yaml)\n- [cqlsh](http://allaboutscala.com/big-data/cassandra/#cqlsh)\n- [Load CQL statements from file](http://allaboutscala.com/big-data/cassandra/#load-cql-statements-from-file)\n- [Partition keys](http://allaboutscala.com/big-data/cassandra/#partition-keys)\n- [Clustering keys](http://allaboutscala.com/big-data/cassandra/#clustering-keys)\n- [Cassandra CQL is not SQL!](http://allaboutscala.com/big-data/cassandra/#cassandra-cql-is-not-sql)\n- [Multiple clustering keys](http://allaboutscala.com/big-data/cassandra/#multiple-clustering-keys)\n- [Clustering keys restrictions](http://allaboutscala.com/big-data/cassandra/#clustering-keys-restrictions)\n- [Secondary index](http://allaboutscala.com/big-data/cassandra/#secondary-index)\n- [Create materialized view](http://allaboutscala.com/#chapter-14-learn-apache-cassandra)\n\n### Chapter 15 - Scala Exercises\n- [Scala Exercises](https://github.com/nadimbahadoor/scala-exercises)\n- [Scala Exercises With Solutions](http://allaboutscala.com/tutorials/scala-exercises-solutions/)\n\n### Chapter 16 - Data Science\n- [Spark NLP Covid-19 versus The Avengers](http://allaboutscala.com/data-science/spark-nlp-covid-19/)\n\nStay 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!\n\n\n## Contact\nNadim Bahadoor at http://allaboutscala.com/contact/\n\n## License\nApache 2.0 License - see the LICENSE.TXT file \n"
  },
  {
    "path": "source-code/allaboutscala/.gitignore",
    "content": "*.class\n*.log\n\n# sbt specific\n.cache\n.history\n.lib/\ndist/*\ntarget/\nlib_managed/\nsrc_managed/\nproject/boot/\nproject/plugins/project/\n\n# Scala-IDE specific\n.scala_dependencies\n.worksheet\n.idea\n"
  },
  {
    "path": "source-code/allaboutscala/build.sbt",
    "content": "name := \"allaboutscala\"\n\nversion := \"1.0\"\n\nscalaVersion := \"2.12.4\"\n\nval scalaLogging = \"com.typesafe.scala-logging\" %% \"scala-logging\" % \"3.8.0\"\nval logback = \"ch.qos.logback\" %  \"logback-classic\" % \"1.1.7\"\nval jodaTime = \"joda-time\" % \"joda-time\" % \"2.9.3\"\nval jodaConvert = \"org.joda\" % \"joda-convert\" % \"1.8\"\n\n\nlibraryDependencies ++= Seq (\n  scalaLogging,\n  logback,\n  jodaTime,\n  jodaConvert\n)"
  },
  {
    "path": "source-code/allaboutscala/project/build.properties",
    "content": "sbt.version = 0.13.8"
  },
  {
    "path": "source-code/allaboutscala/project/plugins.sbt",
    "content": "logLevel := Level.Warn"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Aggregate_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Aggregate Function\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-aggregate-function/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Aggregate_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Set of type String to represent Donut elements\")\n  val donutBasket1: Set[String] = Set(\"Plain Donut\", \"Strawberry Donut\")\n  println(s\"Elements of donutBasket1 = $donutBasket1\")\n\n\n\n  println(\"\\nStep 2: How to define an accumulator function to calculate the total length of the String elements\")\n  val donutLengthAccumulator: (Int, String) => Int = (accumulator, donutName) => accumulator + donutName.length\n\n\n\n  println(\"\\nStep 3: How to call aggregate function with the accumulator function from Step 2\")\n  val totalLength = donutBasket1.aggregate(0)(donutLengthAccumulator, _ + _)\n  println(s\"Total length of elements in donutBasket1 = $totalLength\")\n\n\n\n  println(\"\\nStep 4: How to initialize a Set of Tuple3 elements to represent Donut name, price and quantity\")\n  val donutBasket2: Set[(String, Double, Int)] = Set((\"Plain Donut\", 1.50, 10), (\"Strawberry Donut\", 2.0, 10))\n  println(s\"Elements of donutBasket2 = $donutBasket2\")\n\n\n\n  println(\"\\nStep 5: How to define an accumulator function to calculate the total cost of Donuts\")\n  val totalCostAccumulator: (Double, Double, Int) => Double = (accumulator, price, quantity) => accumulator + (price * quantity)\n\n\n\n  println(\"\\nStep 6: How to call aggregate function with accumulator function from Step 5\")\n  val totalCost = donutBasket2.aggregate(0.0)((accumulator: Double, tuple: (String, Double, Int)) => totalCostAccumulator(accumulator, tuple._2, tuple._3), _ + _)\n  println(s\"Total cost of donuts in donutBasket2 = $totalCost\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Collect_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Collect Function\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-collect-function/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Collect_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence which contains donut names and prices\")\n  val donutNamesandPrices: Seq[Any] = Seq(\"Plain Donut\", 1.5, \"Strawberry Donut\", 2.0, \"Glazed Donut\", 2.5)\n  println(s\"Elements of donutNamesAndPrices = $donutNamesandPrices\")\n\n\n\n  println(\"\\nStep 2: How to use collect function to cherry pick all the donut names\")\n  val donutNames: Seq[String] = donutNamesandPrices.collect{ case name: String => name }\n  println(s\"Elements of donutNames = $donutNames\")\n\n\n\n  println(\"\\nStep 3: How to use collect function to cherry pick all the donut prices\")\n  val donutPrices: Seq[Double] = donutNamesandPrices.collect{ case price: Double => price }\n  println(s\"Elements of donutPrices = $donutPrices\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Diff_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Diff Function\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-diff-function/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Diff_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Set containing 3 donuts\")\n  val donutBasket1: Set[String] = Set(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donutBasket1 = $donutBasket1\")\n\n\n\n  println(\"\\nStep 2: How to initialize a Set containing 2 donuts\")\n  val donutBasket2: Set[String] = Set(\"Glazed Donut\", \"Vanilla Donut\")\n  println(s\"Elements of donutBasket2 = $donutBasket2\")\n\n\n\n  println(\"\\nStep 3: How to find the difference between two Sets using the diff function\")\n  val diffDonutBasket1From2: Set[String] = donutBasket1 diff donutBasket2\n  println(s\"Elements of diffDonutBasket1From2 = $diffDonutBasket1From2\")\n\n\n\n  println(\"\\nStep 4: How to find the difference between two Sets using the diff function\")\n  val diffDonutBasket2From1: Set[String] = donutBasket2 diff donutBasket1\n  println(s\"Elements of diff DonutBasket2From1 = $diffDonutBasket2From1\")\n\n\n\n  println(\"\\nStep 5: How to find the difference between two Sets using the --\")\n  println(s\"Difference between donutBasket1 and donutBasket2 = ${donutBasket1 -- donutBasket2}\")\n  println(s\"Difference between donutBasket2 and donutBasket1 = ${donutBasket2 -- donutBasket1}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/DropWhile_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use DropWhile Function\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-dropwhile-function/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject DropWhile_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to drop elements from the sequence using the dropWhile function\")\n  println(s\"Drop donut elements whose name starts with letter P = ${donuts.dropWhile(_.charAt(0) == 'P')}\")\n\n\n\n  println(\"\\nStep 3: How to declare a predicate function to be passed-through to the dropWhile function\")\n  val dropElementsPredicate: (String) => Boolean = (donutName) => donutName.charAt(0) == 'P'\n  println(s\"Value function dropElementsPredicate = $dropElementsPredicate\")\n\n\n\n  println(\"\\nStep 4: How to drop elements using the predicate function from Step 3\")\n  println(s\"Drop elements using function from Step 3 = ${donuts.dropWhile(dropElementsPredicate)}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Drop_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Drop Function\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-drop-function/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Drop_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to drop the first element using drop function\")\n  println(s\"Drop the first element in the sequence = ${donuts.drop(1)}\")\n\n\n\n  println(\"\\nStep 3: How to drop the first two elements using the drop function\")\n  println(s\"Drop the first and second elements in the sequence = ${donuts.drop(2)}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Exists_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Exists Function\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-exists-function/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Exists_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to check if a particular element exists in the sequence using the exists function\")\n  val doesPlainDonutExists: Boolean = donuts.exists(donutName => donutName == \"Plain Donut\")\n  println(s\"Does Plain Donut exists = $doesPlainDonutExists\")\n\n\n\n  println(\"\\nStep 3: How to declare a predicate value function for the exists function\")\n  val plainDonutPredicate: (String) => Boolean = (donutName) => donutName == \"Plain Donut\"\n  println(s\"Value function plainDonutPredicate = $plainDonutPredicate\")\n\n\n\n  println(\"\\nStep 4: How to find element Plain Donut using the exists function and passing through the predicate function from Step 3\")\n  println(s\"Does Plain Donut exists = ${donuts.exists(plainDonutPredicate)}\")\n\n\n\n  println(\"\\nStep 5: How to declare a predicate def function for the exists function\")\n  def plainDonutPredicateFunction(donutName: String): Boolean = donutName == \"Plain Donut\"\n\n\n\n  println(\"\\nStep 6: How to find element Plain Donut using the exists function and passing through the predicate function from Step 5\")\n  println(s\"Does plain Donut exists = ${donuts.exists(plainDonutPredicateFunction(_))}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/FilterFilterNot_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Filter And FilterNot Function\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-filter-filternot-function/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FilterFilterNot_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\", \"Vanilla Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to keep only Plain and Glazed Donuts using the filter method\")\n  val sequenceWithPlainAndGlazedDonut = donuts.filter { donutName =>\n    donutName.contains(\"Plain\") || donutName.contains(\"Glazed\")\n  }\n  println(s\"Sequence with Plain and Glazed donuts only = $sequenceWithPlainAndGlazedDonut\")\n\n\n\n  println(\"\\nStep 3: How to filter out element Vanilla Donut using the filterNot function\")\n  val sequenceWithoutVanillaDonut = donuts.filterNot(donutName => donutName == \"Vanilla Donut\" )\n  println(s\"Sequence without vanilla donut = $sequenceWithoutVanillaDonut\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Find_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Find Function\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-find-function/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Find_Tutorial extends App {\n\n  println(\"Step 1: Initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to find a particular element in the sequence using the find function\")\n  val plainDonut: Option[String] = donuts.find(donutName => donutName == \"Plain Donut\")\n  println(s\"Find Plain Donut = ${plainDonut.get}\")\n\n\n\n  println(\"\\nStep 3: How to find element Vanilla Donut which does not exists in the sequence using the find function\")\n//  val vanillaDonut: String = donuts.find(_ == \"Vanilla Donut\").get\n//  println(s\"Find Vanilla Donuts = $vanillaDonut\")\n  // NOTE: we get an exception Exception in thread \"main\" java.util.NoSuchElementException: None.get\n\n\n\n  println(\"\\nStep 4: How to find element Vanilla Donut using the find function and getOrElse\")\n  val vanillaDonut2: String = donuts.find(_ == \"Vanilla Donut\").getOrElse(\"Vanilla Donut was not found!\")\n  println(s\"Find Vanilla Donuts = $vanillaDonut2\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/FlatMap_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use FlatMap Function\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-flatmap-function/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FlatMap_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts1: Seq[String] = Seq(\"Plain Donut\", \"Strawberry  Donut\", \"Glazed  Donut\")\n  println(s\"Elements of donuts1 = $donuts1\")\n\n\n\n  println(\"\\nStep 2: How to initialize another Sequence of donuts\")\n  val donuts2: Seq[String] = Seq(\"Vanilla  Donut\", \"Glazed  Donut\")\n  println(s\"Elements of donuts2 = $donuts2\")\n\n\n\n  println(\"\\nStep 3: How to create a List of donuts initialized using the two Sequences from Step 1 and Step 2\")\n  val listDonuts: List[Seq[String]] = List(donuts1, donuts2)\n  println(s\"Elements of listDonuts = $listDonuts\")\n  // NOTE: we have a List(List(Plain Donut, Strawberry  Donut, Glazed  Donut), List(Vanilla  Donut, Glazed  Donut))\n\n\n\n  println(\"\\nStep 4: How to return a single list of donut using the flatMap function\")\n  val listDonutsFromFlatMap: List[String] = listDonuts.flatMap(seq => seq)\n  println(s\"Elements of listDonutsFromFlatMap as a flatMap as a single list = $listDonutsFromFlatMap\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Flatten_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Flatten Function\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-flatten-function-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Flatten_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts1: Seq[String] = Seq(\"Plain\", \"Strawberry\", \"Glazed\")\n  println(s\"Elements of donuts1 = $donuts1\")\n\n\n\n  println(\"\\nStep 2: How to initialize another Sequence of donuts\")\n  val donuts2: Seq[String] = Seq(\"Vanilla\", \"Glazed\")\n  println(s\"Elements of donuts2 = $donuts2\")\n\n\n\n  println(\"\\nStep 3: How to create a List of donuts initialized using the two Sequences from Step 1 and Step 2\")\n  val listDonuts: List[Seq[String]] = List(donuts1, donuts2)\n  println(s\"Elements of listDonuts = $listDonuts\")\n\n\n\n  println(\"\\nStep 4: How to return a single list of donut using the flatten function\")\n  val listDonutsFromFlatten: List[String] = listDonuts.flatten\n  println(s\"Elements of listDonutsFromFlatten = $listDonutsFromFlatten\")\n\n\n\n  println(\"\\nStep 5: How to append the word Donut to each element of listDonuts using flatten and map functions\")\n  val listDonutsFromFlatten2: List[String] = listDonuts.flatten.map(_ + \" Donut\")\n  println(s\"Elements of listDonutsFromFlatten2 = $listDonutsFromFlatten2\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/FoldLeft_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use FoldLeft Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-foldleft-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FoldLeft_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a sequence of donut prices\")\n  val prices: Seq[Double] = Seq(1.5, 2.0, 2.5)\n  println(s\"Donut prices = $prices\")\n\n\n\n  println(\"\\nStep 2: How to sum all the donut prices using foldLeft function\")\n  val sum = prices.foldLeft(0.0)(_ + _)\n  println(s\"Sum = $sum\")\n\n\n\n  println(\"\\nStep 3: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain\", \"Strawberry\", \"Glazed\")\n  println(s\"Elements of donuts1 = $donuts\")\n\n\n\n  println(\"\\nStep 4: How to create a String of all donuts using foldLeft function\")\n  println(s\"All donuts = ${donuts.foldLeft(\"\")((a, b) => a + b + \" Donut \")}\")\n\n\n\n  println(\"\\nStep 5: How to declare a value function to create the donut string\")\n  val concatDonuts: (String, String) => String = (a, b) => a + b + \" Donut \"\n  println(s\"Value function concatDonuts = $concatDonuts\")\n\n\n\n  println(\"\\nStep 6: How to create a String of all donuts using value function from Step 5 and fold function\")\n  println(s\"All donuts = ${donuts.foldLeft(\"\")(concatDonuts)}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/FoldRight_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use FoldRight Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-foldright-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FoldRight_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a sequence of donut prices\")\n  val prices: Seq[Double] = Seq(1.5, 2.0, 2.5)\n  println(s\"Donut prices = $prices\")\n\n\n\n  println(\"\\nStep 2: How to sum all the donut prices using foldRight function\")\n  val sum = prices.foldRight(0.0)(_ + _)\n  println(s\"Sum = $sum\")\n\n\n\n  println(\"\\nStep 3: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain\", \"Strawberry\", \"Glazed\")\n  println(s\"Elements of donuts1 = $donuts\")\n\n\n\n  println(\"\\nStep 4: How to create a String of all donuts using foldRight function\")\n  println(s\"All donuts = ${donuts.foldRight(\"\")((a, b) => a + \" Donut \" + b)}\")\n\n\n\n  println(\"\\nStep 5: How to declare a value function to create the donut string\")\n  val concatDonuts: (String, String) => String = (a, b) => a + \" Donut \" + b\n  println(s\"Value function concatDonuts = $concatDonuts\")\n\n\n\n  println(\"\\nStep 6: How to create a String of all donuts using value function from Step 5 and foldRight function\")\n  println(s\"All donuts = ${donuts.foldRight(\"\")(concatDonuts)}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Fold_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Fold Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-fold-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Fold_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a sequence of donut prices\")\n  val prices: Seq[Double] = Seq(1.5, 2.0, 2.5)\n  println(s\"Donut prices = $prices\")\n\n\n\n  println(\"\\nStep 2: How to sum all the donut prices using fold function\")\n  val sum = prices.fold(0.0)(_ + _)\n  println(s\"Sum = $sum\")\n\n\n\n  println(\"\\nStep 3: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain\", \"Strawberry\", \"Glazed\")\n  println(s\"Elements of donuts1 = $donuts\")\n\n\n\n  println(\"\\nStep 4: How to create a String of all donuts using fold function\")\n  println(s\"All donuts = ${donuts.fold(\"\")((acc, s) => acc + s + \" Donut \")}\")\n\n\n\n  println(\"\\nStep 5: How to declare a value function to create the donut string\")\n  val concatDonuts: (String, String) => String = (s1, s2) => s1 + s2 + \" Donut \"\n  println(s\"Value function concatDonuts = $concatDonuts\")\n\n\n\n  println(\"\\nStep 6: How to create a String of all donuts using value function from Step 5 and fold function\")\n  println(s\"All donuts = ${donuts.fold(\"\")(concatDonuts)}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Foreach_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Foreach Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-foreach-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Foreach_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to loop through all the elements in the sequence using the foreach function\")\n  donuts.foreach(println(_))\n\n\n\n  println(\"\\nStep 3: How to loop through and access all the elements in the sequence using the foreach function\")\n  donuts.foreach(donutName => println(s\"donutName = $donutName\"))\n\n\n\n  println(\"\\nStep 4: How to declare a value function to format a donut names into upper case format\")\n  val uppercase: (String) => String = (s) => {\n    val upper = s.toUpperCase\n    println(upper)\n    upper\n  }\n  println(s\"Value function formatting donut names to uppercase = $uppercase\")\n\n\n\n  println(\"\\nStep 5: How to format all donuts to uppercase using value function from Step 4\")\n  donuts.foreach(uppercase)\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/GroupBy_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use GroupBy Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-groupby-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject GroupBy_Tutorial extends App {\n\n  println(\"\\nStep 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to group elements in a sequence using the groupBy function\")\n  val donutsGroup: Map[Char, Seq[String]] = donuts.groupBy(_.charAt(0))\n  println(s\"Group elements in the donut sequence by the first letter of the donut name = $donutsGroup\")\n\n\n\n  println(\"\\nStep 3: How to create a case class to represent Donut objects\")\n  case class Donut(name: String, price: Double)\n\n\n\n  println(\"\\nStep 4: How to create a Sequence of type Donut\")\n  val donuts2: Seq[Donut] = Seq(Donut(\"Plain Donut\", 1.5), Donut(\"Strawberry Donut\", 2.0), Donut(\"Glazed Donut\", 2.5))\n  println(s\"Elements of donuts2 = $donuts2\")\n\n\n\n  println(s\"\\nStep 5: How to group case classes donut objects by the name property\")\n  val donutsGroup2: Map[String, Seq[Donut]] = donuts2.groupBy(_.name)\n  println(s\"Group element in the sequence of type Donut grouped by the donut name = $donutsGroup2\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Head_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Head Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-head-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Head_Tutorial extends App {\n\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to access the first element of the donut sequence\")\n  println(s\"First element of donut sequence = ${donuts(0)}\")\n\n\n\n  println(\"\\nStep 3: How to access the first element of the donut sequence using the head method\")\n  println(s\"First element of donut sequence using head method = ${donuts.head}\")\n\n\n\n  println(\"\\nStep 4: How to create an empty sequence\")\n  val donuts2: Seq[String] = Seq.empty[String]\n  println(s\"Elements of donuts2 = $donuts2\")\n\n\n\n  println(\"\\nStep 5: How to access the first element of the donut sequence using the headOption function\")\n  println(s\"First element of empty sequence = ${donuts2.headOption.getOrElse(\"No donut was found!\")}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Intersect_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Intersect Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-intersect-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Intersect_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Set of donuts\")\n  val donuts1: Set[String] = Set(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts1 = $donuts1\")\n\n\n\n  println(\"\\nStep 2: How to initialize another Set of donuts\")\n  val donuts2: Set[String] = Set(\"Plain Donut\", \"Chocolate Donut\", \"Vanilla Donut\")\n  println(s\"Elements of donuts2 = $donuts2\")\n\n\n\n  println(\"\\nStep 3: How to find the common elements between two Sets using intersect function\")\n  println(s\"Common elements between donuts1 and donuts2 = ${donuts1 intersect donuts2}\")\n  println(s\"Common elements between donuts2 and donuts1 = ${donuts2 intersect donuts1}\")\n\n\n\n  println(\"\\nStep 4: How to find the common elements between two Sets using & function\")\n  println(s\"Common elements between donuts1 and donuts2 = ${donuts1 & donuts2}\")\n  println(s\"Common elements between donuts2 and donuts1 = ${donuts2 & donuts1}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/IsEmpty_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use IsEmpty Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-isempty-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject IsEmpty_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to find out if a sequence is empty using isEmpty function\")\n  println(s\"Is donuts sequence empty = ${donuts.isEmpty}\")\n\n\n\n  println(\"\\nStep 3: How to create an empty sequence\")\n  val donuts2: Seq[String] = Seq.empty[String]\n  println(s\"Elements of donuts2 = $donuts2\")\n\n\n\n  println(\"\\nStep 4: How to find out if a sequence is empty using isEmpty function\")\n  println(s\"Is donuts2 sequence empty = ${donuts2.isEmpty}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Last_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Last Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-last-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Last_Tutorial extends App {\n\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to access the last element of the donut sequence by index\")\n  println(s\"Last element of donut sequence = ${donuts(donuts.size - 1)}\")\n\n\n\n  println(\"\\nStep 3: How to access the last element of the donut sequence by using the last function\")\n  println(s\"Last element of donut sequence = ${donuts.last}\")\n\n\n\n  println(\"\\nStep 4: How to create an empty sequence\")\n  val donuts2: Seq[String] = Seq.empty[String]\n  println(s\"Elements of donuts2 = $donuts2\")\n\n\n\n  println(\"\\nStep 5: How to access the last element of the donut sequence using the lastOption function\")\n  println(s\"Last element of empty sequence = ${donuts2.lastOption.getOrElse(\"No donut was found!\")}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Map_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Map Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-map-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Map_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts1: Seq[String] = Seq(\"Plain\", \"Strawberry\", \"Glazed\")\n  println(s\"Elements of donuts1 = $donuts1\")\n\n\n\n  println(\"\\nStep 2: How to append the word Donut to each element using the map function\")\n  val donuts2: Seq[String] = donuts1.map(_ + \" Donut\")\n  println(s\"Elements of donuts2 = $donuts2\")\n\n\n\n  println(\"\\nStep 3: How to create a donut sequence with one None element\")\n  val donuts3: Seq[AnyRef] = Seq(\"Plain\", \"Strawberry\", None)\n  donuts3.foreach(println(_))\n\n\n\n  println(\"\\nStep 4: How to filter out the None element using map function\")\n  val donuts4: Seq[String] = donuts3.map {\n    case donut: String => donut + \" Donut\"\n    case None => \"Unknown Donut\"\n  }\n  println(s\"Elements of donuts4 = $donuts4\")\n\n\n\n  println(\"\\nStep 5: How to define couple of functions which returns an Option of type String\")\n  def favoriteDonut: Option[String] = Some(\"Glazed Donut\")\n\n  def leastFavoriteDonut: Option[String] = None\n\n\n\n  println(\"\\nStep 6: How to use map function to filter out None values\")\n  favoriteDonut.map(donut => println(s\"Favorite donut = $donut\"))\n  leastFavoriteDonut.map(donut=> println(s\"Least favorite donut = $donut\"))\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/MaxBy_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use MaxBy Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-maxby-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject MaxBy_Tutorial extends App {\n\n  println(\"Step 1: How to create a case class to represent Donut object\")\n  case class Donut(name: String, price: Double)\n\n\n\n  println(\"\\nStep 2: How to create a Sequence of type Donut\")\n  val donuts: Seq[Donut] = Seq(Donut(\"Plain Donut\", 1.5), Donut(\"Strawberry Donut\", 2.0), Donut(\"Glazed Donut\", 2.5))\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 3: How to find the maximum element in a sequence of case classes objects using the maxBy function\")\n  println(s\"Maximum element in sequence of case class of type Donut, ordered by price = ${donuts.maxBy(donut => donut.price)}\")\n\n\n\n  println(\"\\nStep 4: How to declare a value predicate function for maxBy function\")\n  val donutsMaxBy: (Donut) => Double = (donut) => donut.price\n  println(s\"Value function donutMaxBy = $donutsMaxBy\")\n\n\n\n  println(\"\\nStep 5: How to find the maximum element using maxBy function and pass through the predicate function from Step 4\")\n  println(s\"Maximum element in sequence using function from Step 3 = ${donuts.maxBy(donutsMaxBy)}\")\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Max_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Max Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-max-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Max_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to find the maximum element in the sequence using the max function\")\n  println(s\"Max element in the donuts sequence = ${donuts.max}\")\n\n\n\n  println(\"\\nStep 3: How to initialize donut prices\")\n  val prices: Seq[Double] = Seq(1.50, 2.0, 2.50)\n  println(s\"Elements of prices = $prices\")\n\n\n\n  println(\"\\nStep 4: How to find the maximum element in the sequence using the max function\")\n  println(s\"Max element in the donut prices sequence = ${prices.max}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/MinBy_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use MinBy Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-minby-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject MinBy_Tutorial extends App {\n\n  println(\"Step 1: How to create case class to represent Donut object\")\n  case class Donut(name: String, price: Double)\n\n\n\n  println(\"\\nStep 2: How to create a Sequence of type Donut\")\n  val donuts: Seq[Donut] = Seq(Donut(\"Plain Donut\", 1.5), Donut(\"Strawberry Donut\", 2.0), Donut(\"Glazed Donut\", 2.5))\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 3: How to find the minimum element in a sequence of case classes using the minBy function\")\n  println(s\"Minimum element in sequence of case class of type Donut, ordered by price = ${donuts.minBy(donut => donut.price)}\")\n\n\n\n  println(\"\\nStep 4: How to declare a value predicate function for minBy function\")\n  val donutsMinBy: (Donut) => Double = (donut) => donut.price\n  println(s\"Value function donutMinBy = $donutsMinBy\")\n\n\n\n  println(\"\\nStep 5: How to find the minimum element using minBy function and passing through the predicate function from Step 4\")\n  println(s\"Minimum element in sequence using function from Step 3 = ${donuts.minBy(donutsMinBy)}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Min_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Min Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-min-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Min_Tutorial extends App {\n\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to find the minimum element in the sequence using the min function\")\n  println(s\"Min element in the donuts sequence = ${donuts.min}\")\n\n\n\n  println(\"\\nStep 3: How to initialize a Sequence of donut prices\")\n  val prices: Seq[Double] = Seq(1.50, 2.0, 2.50)\n  println(s\"Elements of prices = $prices\")\n\n\n\n  println(\"\\nStep 4: How to find the minimum element in the sequence using the min function\")\n  println(s\"Min element in the donut prices sequence = ${prices.min}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/MkString_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use MkString Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-mkstring-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject MkString_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to concatenate the elements of a sequence into a String using mkString function\")\n  val donutsAsString: String = donuts.mkString(\" and \")\n  println(s\"Donuts elements using mkString function = $donutsAsString\")\n\n\n\n  println(\"\\nStep 3: How to concatenate the elements of a sequence into a String using mkString and specifying prefix and suffix\")\n  val donutsWithPrefixAndSuffix: String = donuts.mkString(\"My favorite donuts namely \", \" and \", \" are very tasty!\")\n  println(s\"$donutsWithPrefixAndSuffix\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/NonEmpty_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use NonEmpty Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-nonempty-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject NonEmpty_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to check if a sequence is not empty using nonEmpty function\")\n  println(s\"Is donuts sequence NOT empty = ${donuts.nonEmpty}\")\n\n\n\n  println(\"\\nStep 3: How to create an empty sequence\")\n  val emptyDonuts: Seq[String] = Seq.empty[String]\n  println(s\"Elements of emptyDonuts = $emptyDonuts\")\n\n\n\n  println(\"\\nStep 4: How to find out if sequence is empty using nonEmpty function\")\n  println(s\"Is emptyDonuts sequence empty = ${emptyDonuts.nonEmpty}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Par_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Par Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-par-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Par_Tutorial extends App {\n\n  println(\"Step 1: How to initialize an Immutable Sequence of various donut flavours\")\n  val donutFlavours: Seq[String] = Seq(\"Plain\", \"Strawberry\", \"Glazed\")\n  println(s\"Elements of donutFlavours immutable sequence = $donutFlavours\")\n\n\n\n  println(\"\\nStep 2: Convert the Immutable donut flavours Sequence into Parallel Collection\")\n  import scala.collection.parallel.ParSeq\n  val donutFlavoursParallel: ParSeq[String] = donutFlavours.par\n\n\n\n  println(\"\\nStep 3: How to use Scala Parallel Collection\")\n  val donuts: ParSeq[String] = donutFlavoursParallel.map(d => s\"$d donut\")\n  println(s\"Elements of donuts parallel collection = $donuts\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Partition_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Partition Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-partition-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Partition_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a sequence which contains donut names and prices\")\n  val donutNamesAndPrices: Seq[Any] = Seq(\"Plain Donut\", 1.5, \"Strawberry Donut\", 2.0, \"Glazed Donut\", 2.5)\n  println(s\"Elements of donutNamesAndPrices = $donutNamesAndPrices\")\n\n\n\n  println(\"\\nStep 2: How to split the sequence by the element types using partition function\")\n  val namesAndPrices: (Seq[Any], Seq[Any]) = donutNamesAndPrices.partition {\n    case name: String => true\n    case price: Double => false\n  }\n  println(s\"Elements of namesAndPrices = $namesAndPrices\")\n\n\n\n  println(\"\\nStep 3: How to access the donut String sequence from Step 2\")\n  println(s\"Donut names = ${namesAndPrices._1}\")\n\n\n\n  println(\"\\nStep 4: How to access the donut prices sequence from Step 2\")\n  println(s\"Donut prices = ${namesAndPrices._2}\")\n\n\n\n  println(\"\\nStep 5: How to extract the pair returned by partition function\")\n  val (donutNames, donutPrices) = donutNamesAndPrices.partition {\n    case name: String => true\n    case _ => false\n  }\n  println(s\"donutNames = $donutNames\")\n  println(s\"donutPrices = $donutPrices\")\n\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ReduceLeft_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use ReduceLeft Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reduceleft-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ReduceLeft_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a sequence of donut prices\")\n  val donutPrices: Seq[Double] = Seq(1.5, 2.0, 2.5)\n  println(s\"Elements of donutPrices = $donutPrices\")\n\n\n\n  println(\"\\nStep 2: How to find the sum of the elements using reduceLeft function\")\n  val sum: Double = donutPrices.reduceLeft(_ + _)\n  println(s\"Sum of elements from donutPrices = $sum\")\n\n\n\n  println(\"\\nStep 3: How to find the sum of elements using reduceLeft function explicitly\")\n  val sum1: Double = donutPrices.reduceLeft((a, b) => a + b)\n  println(s\"Sum of elements from donutPrices by calling reduceLeft function explicitly= $sum1\")\n\n\n\n  println(\"\\nStep 4: How to find the cheapest donut using reduceLeft function\")\n  println(s\"Cheapest donut price = ${donutPrices.reduceLeft(_ min _)}\")\n\n\n\n  println(\"\\nStep 5: How to find the most expensive donut using reduceLeft function\")\n  println(s\"Most expensive donut price = ${donutPrices.reduceLeft(_ max _)}\")\n\n\n\n  println(\"\\nStep 6: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 7: How to concatenate the elements from the sequence using reduceLeft function\")\n  println(s\"Elements of donuts sequence concatenated = ${donuts.reduceLeft((left, right) => left + \", \" + right)}\")\n\n\n\n  println(\"\\nStep 8: How to declare a value function to concatenate donut names\")\n  val concatDonutNames: (String, String) => String = (left, right) => {\n    left + \", \" + right\n  }\n  println(s\"Value function concatDonutNames = $concatDonutNames\")\n\n\n\n  println(\"\\nStep 9: How to pass a function to reduceLeft function\")\n  println(s\"Elements of donuts sequence concatenated by passing function to the reduceLeft function = ${donuts reduceLeft concatDonutNames}\")\n\n\n\n  println(\"\\nStep 10: How to use reduceLeftOption to avoid exception if the collection is empty \")\n  println(s\"Using reduceLeftOption will NOT throw any exception = ${Seq.empty[String].reduceLeftOption(_ + \", \" + _)}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ReduceRight_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use ReduceRight Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reduceright-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ReduceRight_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a sequence of donut prices\")\n  val donutPrices: Seq[Double] = Seq(1.5, 2.0, 2.5)\n  println(s\"Elements of donutPrices = $donutPrices\")\n\n\n\n  println(\"\\nStep 2: How to find the sum of the elements using reduceRight function\")\n  val sum: Double = donutPrices.reduceRight(_ + _)\n  println(s\"Sum of elements from donutPrices = $sum\")\n\n\n\n  println(\"\\nStep 3: How to find the sum of elements using reduceRight function explicitly\")\n  val sum1: Double = donutPrices.reduceRight((a, b) => a + b)\n  println(s\"Sum of elements from donutPrices by calling reduceRight function explicitly= $sum1\")\n\n\n\n  println(\"\\nStep 4: How to find the cheapest donut using reduceRight function\")\n  println(s\"Cheapest donut price = ${donutPrices.reduceRight(_ min _)}\")\n\n\n\n  println(\"\\nStep 5: How to find the most expensive donut using reduceRight function\")\n  println(s\"Most expensive donut price = ${donutPrices.reduceRight(_ max _)}\")\n\n\n\n  println(\"\\nStep 6: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 7: How to concatenate the elements from the sequence using reduceRight function\")\n  println(s\"Elements of donuts sequence concatenated = ${donuts.reduceRight((left, right) => left + \", \" + right)}\")\n\n\n\n  println(\"\\nStep 8: How to declare a value function to concatenate donut names\")\n  val concatDonutNames: (String, String) => String = (left, right) => {\n    left + \", \" + right\n  }\n  println(s\"Value function concatDonutNames = $concatDonutNames\")\n\n\n\n  println(\"\\nStep 9: How to pass a function to reduceRight function\")\n  println(s\"Elements of donuts sequence concatenated by passing function to the reduce function = ${donuts reduceRight concatDonutNames}\")\n\n\n\n  println(\"\\nStep 10: How to use option reduce right function to avoid exception if collection is empty\")\n  println(s\"Using reduce right option will NOT throw any exception = ${Seq.empty[String].reduceRightOption(_ + \", \" + _)}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Reduce_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Reduce Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reduce-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Reduce_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a sequence of donut prices\")\n  val donutPrices: Seq[Double] = Seq(1.5, 2.0, 2.5)\n  println(s\"Elements of donutPrices = $donutPrices\")\n\n\n\n  println(\"\\nStep 2: How to find the sum of the elements using reduce function\")\n  val sum: Double = donutPrices.reduce(_ + _)\n  println(s\"Sum of elements from donutPrices = $sum\")\n\n\n\n  println(\"\\nStep 3: How to find the sum of elements using reduce function explicitly\")\n  val sum1: Double = donutPrices.reduce((a, b) => a + b)\n  println(s\"Sum of elements from donutPrices by calling reduce function explicitly= $sum1\")\n\n\n\n  println(\"\\nStep 4: How to find the cheapest donut using reduce function\")\n  println(s\"Cheapest donut price = ${donutPrices.reduce(_ min _)}\")\n\n\n\n  println(\"\\nStep 5: How to find the most expensive donut using reduce function\")\n  println(s\"Most expensive donut price = ${donutPrices.reduce(_ max _)}\")\n\n\n\n  println(\"\\nStep 6: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 7: How to concatenate the elements from the sequence using reduce function\")\n  println(s\"Elements of donuts sequence concatenated = ${donuts.reduce((left, right) => left + \", \" + right)}\")\n\n\n\n  println(\"\\nStep 8: How to declare a value function to concatenate donut names\")\n  val concatDonutNames: (String, String) => String = (left, right) => {\n    left + \", \" + right\n  }\n  println(s\"Value function concatDonutNames = $concatDonutNames\")\n\n\n\n  println(\"\\nStep 9: How to pass a function to reduce function\")\n  println(s\"Elements of donuts sequence concatenated by passing function to the reduce function = ${donuts reduce concatDonutNames}\")\n\n\n\n  println(\"\\nStep 10: How to use option reduce to avoid exception if the collection is empty \")\n  println(s\"Using reduce option will NOT throw any exception = ${Seq.empty[String].reduceOption(_ + \", \" + _)}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ReverseIterator.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use ReverseIterator Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reverseiterator-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ReverseIterator extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to print all elements in reverse order using reverseIterator function\")\n  println(s\"Elements of donuts in reversed order = ${donuts.reverseIterator.toList}\")\n\n\n\n  println(\"\\nStep 3: How to iterate through elements using foreach method\")\n  val reverseIterator: Iterator[String] = donuts.reverseIterator\n  reverseIterator.foreach(donut => println(s\"donut = $donut\"))\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Reverse_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Reverse Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-reverse-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Reverse_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to get the elements of the sequence in reverse using the reverse method\")\n  println(s\"Elements of donuts in reversed order = ${donuts.reverse}\")\n\n\n\n  println(\"\\nStep 3: How to access each reversed element using reverse and foreach methods\")\n  donuts.reverse.foreach(donut => println(s\"donut = $donut\"))\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ScanLeft_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use ScanLeft Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-scanleft-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ScanLeft_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a sequence of numbers\")\n  val numbers: Seq[Int] = Seq(1, 2, 3, 4, 5)\n  println(s\"Elements of numbers = $numbers\")\n\n\n\n  println(\"\\nStep 2: How to create a running total using the scanLeft function\")\n  val runningTotal: Seq[Int] = numbers.scanLeft(0)(_ + _)\n  println(s\"Running total of all elements in the collection = $runningTotal\")\n  // NOTE: scanLeft method iterations\n  // 0 + 1             =   1\n  // 1 + 2             =   3\n  // 1 + 2 + 3         =   6\n  // 1 + 2 + 3 + 4     =   10\n  // 1 + 2 + 3 + 4 + 5 =   15\n\n\n\n  println(\"\\nStep 3: How to create a running total using the scanLeft function explicitly\")\n  val runningTotal2: Seq[Int] = numbers.scanLeft(0)((a, b) => a + b)\n  println(s\"Running total of all elements in the collection = $runningTotal2\")\n  // NOTE: scanLeft method iterations\n  // 0 + 1             =   1\n  // 1 + 2             =   3\n  // 1 + 2 + 3         =   6\n  // 1 + 2 + 3 + 4     =   10\n  // 1 + 2 + 3 + 4 + 5 =   15\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ScanRight_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use ScanRight Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-scanright-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ScanRight_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a sequence of numbers\")\n  val numbers: Seq[Int] = Seq(1, 2, 3, 4, 5)\n  println(s\"Elements of numbers = $numbers\")\n\n\n\n  println(\"\\nStep 2: How to create a running total using the scanRight function\")\n  val runningTotal: Seq[Int] = numbers.scanRight(0)(_ + _)\n  println(s\"Running total of all elements in the collection = $runningTotal\")\n  // NOTE: scanRight method iterations\n  // 5 + 4 + 3 + 2 + 1   = 15\n  // 5 + 4 + 3 + 2       = 14\n  // 5 + 4 + 3           = 12\n  // 5 + 4               = 9\n  // 5 + 0               = 5\n  // 0                   = 0\n\n\n\n  println(\"\\nStep 3: How to create a running total using the scanRight function explicitly\")\n  val runningTotal2: Seq[Int] = numbers.scanRight(0)((a, b) => a + b)\n  println(s\"Running total of all elements in the collection = $runningTotal2\")\n  // NOTE: scanRight method iterations\n  // 5 + 4 + 3 + 2 + 1   = 15\n  // 5 + 4 + 3 + 2       = 14\n  // 5 + 4 + 3           = 12\n  // 5 + 4               = 9\n  // 5 + 0               = 5\n  // 0                   = 0\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Scan_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scan Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-scan-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Scan_Tutorial extends App {\n\n\n  println(\"Step 1: How to initialize a sequence of numbers\")\n  val numbers: Seq[Int] = Seq(1, 2, 3, 4, 5)\n  println(s\"Elements of numbers = $numbers\")\n\n\n\n  println(\"\\nStep 2: How to create a running total using the scan function\")\n  val runningTotal: Seq[Int] = numbers.scan(0)(_ + _)\n  println(s\"Running total of all elements in the collection = $runningTotal\")\n  // NOTE:  scan method iterations\n  // 0 + 1             =   1\n  // 1 + 2             =   3\n  // 1 + 2 + 3         =   6\n  // 1 + 2 + 3 + 4     =   10\n  // 1 + 2 + 3 + 4 + 5 =   15\n\n\n\n  println(\"\\nStep 3: How to create a running total using the scan function explicitly\")\n  val runningTotal2: Seq[Int] = numbers.scan(0)((a, b) => a + b)\n  println(s\"Running total of all elements in the collection = $runningTotal2\")\n  // NOTE:  scan method iterations\n  // 0 + 1             =   1\n  // 1 + 2             =   3\n  // 1 + 2 + 3         =   6\n  // 1 + 2 + 3 + 4     =   10\n  // 1 + 2 + 3 + 4 + 5 =   15\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Size_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Size Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-size-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Size_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to count the number of elements in the sequence using size function\")\n  println(s\"Size of donuts sequence = ${donuts.size}\")\n\n\n\n  println(\"\\nStep 3: How to use the count function\")\n  println(s\"Number of times element Plain Donut appear in donuts sequence = ${donuts.count(_ == \"Plain Donut\")}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Slice_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Slice Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-slice-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Slice_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to take a section from the sequence using the slice function\")\n  println(s\"Take elements from the sequence from index 0 to 1 = ${donuts.slice(0,1)}\")\n  println(s\"Take elements from the sequence from index 0 to 2 = ${donuts.slice(0,2)}\")\n  println(s\"Take elements from the sequence from index 0 to 3 = ${donuts.slice(0,3)}\")\n\n\n\n  println(\"\\nStep 3: How to use slice function where the index is out of range\")\n  println(s\"Take elements from the sequence from index 0 to 4 = ${donuts.slice(0,4)}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/SortBy_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use SortBy Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-sortby-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject SortBy_Tutorial extends App {\n\n  println(\"\\nStep 1: How to create a case class to represent Donut objects\")\n  case class Donut(name: String, price: Double)\n\n\n\n  println(\"\\nStep 2: How to create a Sequence of type Donut\")\n  val donuts: Seq[Donut] = Seq(Donut(\"Plain Donut\", 1.5), Donut(\"Strawberry Donut\", 2.0), Donut(\"Glazed Donut\", 2.5))\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 3: How to sort a sequence of case class objects using the sortBy function\")\n  println(s\"Sort a sequence of case class objects of type Donut, sorted by price = ${donuts.sortBy(donut => donut.price)}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/SortWith_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use SortWith Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-sortwith-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject SortWith_Tutorial extends App {\n\n  println(\"\\nStep 1: How to create a case class to represent Donut objects\")\n  case class Donut(name: String, price: Double)\n\n\n\n  println(\"\\nStep 2: How to create a Sequence of type Donut\")\n  val donuts: Seq[Donut] = Seq(Donut(\"Plain Donut\", 1.5), Donut(\"Strawberry Donut\", 2.0), Donut(\"Glazed Donut\", 2.5))\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 3: How to sort a sequence of case class objects using the sortWith function\")\n  println(s\"Sort a sequence of case classes of type Donut, sorted with price = ${donuts.sortWith(_.price < _.price)}\")\n\n\n\n  println(\"\\nStep 4: How to sort a sequence of case class objects in ascending order using the sortWith function\")\n  println(s\"Sort a sequence of case classes of type Donut, sorted with price in ascending order = ${donuts.sortWith(_.price < _.price)}\")\n  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)}\")\n\n\n\n  println(\"\\nStep 5: How to sort a sequence of case class objects in descending order using the sortWith function\")\n  println(s\"Sort a sequence of case classes of type Donut, sorted with price in descending order = ${donuts.sortWith(_.price > _.price)}\")\n  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)}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Sorted_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Sorted Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-sorted-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Sorted_Tutorial extends App {\n\n  println(\"Step 1: How to initialize donut prices\")\n  val prices: Seq[Double] = Seq(1.50, 2.0, 2.50)\n  println(s\"Elements of prices = $prices\")\n\n\n\n  println(\"\\nStep 2: How to sort a sequence of type Double using the sorted function\")\n  println(s\"Sort a sequence of type Double by their natural ordering = ${prices.sorted}\")\n\n\n\n  println(\"\\nStep 3: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 4: How to sort a sequence of type String using the sorted function\")\n  println(s\"Sort a sequence of type String by their natural ordering = ${donuts.sorted}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Tail_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Tail Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-tail-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tail_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to return all elements in the sequence except the head using the tail function\")\n  println(s\"Elements of donuts excluding the head = ${donuts.tail}\")\n\n\n\n  println(\"\\nStep 3: How to access the last element of the donut sequence by using the last function\")\n  println(s\"Last element of donut sequence = ${donuts.last}\")\n\n\n\n  println(\"\\nStep 4: How to access the first element of the donut sequence by using the head function\")\n  println(s\"First element of donut sequence = ${donuts.head}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/TakeRight_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use TakeRight Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-takeright-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject TakeRight_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a List of donuts\")\n  val donuts: Seq[String] = List(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to take the last N elements using the takeRight function\")\n  println(s\"Take the last donut element in the sequence =  ${donuts.takeRight(1)}\")\n  println(s\"Take the last two donut elements in the sequence =  ${donuts.takeRight(2)}\")\n  println(s\"Take the last three donut elements in the sequence =  ${donuts.takeRight(3)}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/TakeWhile_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use TakeWhile Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-takewhile-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject TakeWhile_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a List of donuts\")\n  val donuts: Seq[String] = List(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to take elements from the List using the takeWhile function\")\n  println(s\"Take donut elements which start with letter P = ${donuts.takeWhile(_.charAt(0) == 'P')}\")\n\n\n\n  println(\"\\nStep 3: How to declare a predicate function to be passed-through to the takeWhile function\")\n  val takeDonutPredicate: (String) => Boolean = (donutName) => donutName.charAt(0) == 'P'\n  println(s\"Value function takeDonutPredicate = $takeDonutPredicate\")\n\n\n\n  println(\"\\nStep 4: How to take elements using the predicate function from Step 3\")\n  println(s\"Take elements using function from Step 3 = ${donuts.takeWhile(takeDonutPredicate)}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Take_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Take Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-take-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Take_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to take elements from the sequence using the take function\")\n  println(s\"Take the first donut element in the sequence =  ${donuts.take(1)}\")\n  println(s\"Take the first and second donut elements in the sequence =  ${donuts.take(2)}\")\n  println(s\"Take the first, second and third donut elements in the sequence =  ${donuts.take(3)}\")\n}"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Transpose_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Transpose Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-transpose-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Transpose_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to initialize donut prices\")\n  val prices: Seq[Double] = Seq(1.50, 2.0, 2.50)\n  println(s\"Elements of prices = $prices\")\n\n\n\n  println(\"\\nStep 3: How to create a List of donuts and prices\")\n  val donutList = List(donuts, prices)\n  println(s\"Sequence of donuts and prices = $donutList\")\n\n\n\n  println(\"\\nStep 4: How to pair each element from both donuts and prices Sequences using the transpose function\")\n  println(s\"Transposed list of donuts paired with their individual prices = ${donutList.transpose}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Union_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Union Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-union-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Union_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Set of donuts\")\n  val donuts1: Set[String] = Set(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts1 = $donuts1\")\n\n\n\n  println(\"\\nStep 2: How to initialize another Set of donuts\")\n  val donuts2: Set[String] = Set(\"Plain Donut\", \"Chocolate Donut\", \"Vanilla Donut\")\n  println(s\"Elements of donuts2 = $donuts2\")\n\n\n\n  println(\"\\nStep 3: How to merge two Sets using union function\")\n  println(s\"Union of Sets donuts1 and donuts2 = ${donuts1 union donuts2}\")\n  println(s\"Union of Sets donuts2 and donuts1 = ${donuts2 union donuts1}\")\n\n\n\n  println(\"\\nStep 4: How to merge two Sets using ++ function\")\n  println(s\"Union of Sets donuts1 and donuts2 = ${donuts1 ++ donuts2}\")\n  println(s\"Union of Sets donuts2 and donuts1 = ${donuts2 ++ donuts1}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Unzip3_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Unzip3 Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-unzip3-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Unzip3_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of Tuple3 elements\")\n  val donuts: Seq[(String, Double, String)] = Seq((\"Plain Donut\",1.5,\"Tasty\"), (\"Glazed Donut\",2.0,\"Very Tasty\"), (\"Strawberry Donut\",2.5,\"Very Tasty\"))\n  println(s\"Donuts tuple3 elements = $donuts\")\n\n\n  println(\"\\nStep 2: How to call unzip3 function to unzip Tuple3 elements\")\n  val unzipped: (Seq[String], Seq[Double], Seq[String]) = donuts.unzip3\n  println(s\"Unzipped donut names = ${unzipped._1}\")\n  println(s\"Unzipped donut prices = ${unzipped._2}\")\n  println(s\"Unzipped donut taste = ${unzipped._3}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Unzip_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Unzip Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-unzip-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Unzip_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to initialize a Sequence of donut prices\")\n  val donutPrices = Seq[Double](1.5, 2.0, 2.5)\n  println(s\"Elements of donut prices = $donutPrices\")\n\n\n\n  println(\"\\nStep 3: How to zip the donuts Sequence with their corresponding prices\")\n  val zippedDonutsAndPrices: Seq[(String, Double)] = donuts zip donutPrices\n  println(s\"Zipped donuts and prices = $zippedDonutsAndPrices\")\n\n\n\n  println(\"\\nStep 4: How to unzip the zipped donut sequence into separate donuts names and prices Sequences\")\n  val unzipped: (Seq[String], Seq[Double]) = zippedDonutsAndPrices.unzip\n  println(s\"Donut names unzipped = ${unzipped._1}\")\n  println(s\"Donut prices unzipped = ${unzipped._2}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ViewTutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use View Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-view-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ViewTutorial extends App {\n\n  println(\"Step 1: How to create a large numeric range and take the first 10 odd numbers\")\n  val largeOddNumberList: List[Int] = (1 to 1000000).filter(_ % 2 != 0).take(10).toList\n  println(s\"First 100 odd numbers from largeOddNumberList = ${largeOddNumberList}\")\n\n\n\n  println(s\"\\nStep 2: How to lazily create a large numeric range and take the first 10 odd numbers\")\n  val lazyLargeOddNumberList = (1 to 1000000).view.filter(_ % 2 != 0).take(10).toList\n  println(s\"Lazily take the first 100 odd numbers from lazyLargeOddNumberList = ${lazyLargeOddNumberList}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/WithFilter_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use WithFilter Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-withfilter-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject WithFilter_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = List(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to filter elements using the withFilter function\")\n  donuts\n    .withFilter(_.charAt(0) == 'P')\n    .foreach(donut => println(s\"Donut starting with letter P = $donut\"))\n}\n\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/ZipWIthIndex.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use ZipWithIndex Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-zipwithindex-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ZipWIthIndex extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to zip the donuts Sequence with their corresponding index using zipWithIndex method\")\n  val zippedDonutsWithIndex: Seq[(String, Int)] = donuts.zipWithIndex\n  zippedDonutsWithIndex.foreach{ donutWithIndex =>\n    println(s\"Donut element = ${donutWithIndex._1} is at index = ${donutWithIndex._2}\")\n  }\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/eight/Zip_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.eight\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Zip Function With Examples\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-8-beginner-tutorial-using-scala-collection-functions/scala-zip-example/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Zip_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence of donuts\")\n  val donuts: Seq[String] = Seq(\"Plain Donut\", \"Strawberry Donut\", \"Glazed Donut\")\n  println(s\"Elements of donuts = $donuts\")\n\n\n\n  println(\"\\nStep 2: How to initialize a Sequence of donut prices\")\n  val donutPrices: Seq[Double] = Seq(1.5, 2.0, 2.5)\n  println(s\"Elements of donut prices = $donutPrices\")\n\n\n\n  println(\"\\nStep 3: How to use zip method to zip two collections\")\n  val zippedDonutsAndPrices: Seq[(String, Double)] = donuts zip donutPrices\n  println(s\"Zipped donuts and prices = $zippedDonutsAndPrices\")\n\n\n\n  println(\"\\nStep 4: How to use unzip method to un-merge a zipped collections\")\n  val unzipped: (Seq[String], Seq[Double]) = zippedDonutsAndPrices.unzip\n  println(s\"Donut names unzipped = ${unzipped._1}\")\n  println(s\"Donut prices unzipped = ${unzipped._2}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/five/ExtendMultipleTraits.scala",
    "content": "package com.allaboutscala.chapter.five\n\n/**\n  * /**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Extend Multiple Traits\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-5-traits/scala-extend-multiple-traits/]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\n  */\nobject ExtendMultipleTraits extends App {\n\n    println(\"Step 1: Create a trait with type which will define the methods for a data access layer\")\n    trait DonutShoppingCartDao[A] {\n\n      def add(donut: A): Long\n\n      def update(donut: A): Boolean\n\n      def search(donut: A): A\n\n      def delete(donut: A): Boolean\n    }\n\n\n\n    println(\"\\nStep 2: Create a second trait which will define the methods for checking donut inventory\")\n    trait DonutInventoryService[A] {\n\n      def checkStockQuantity(donut: A): Int\n\n    }\n\n\n    println(\"\\nStep 3: Create a DonutShoppingCart class which extends multiple traits namely trait DonutShoppingCartDao and trait DonutInventoryService\")\n    class DonutShoppingCart[A] extends DonutShoppingCartDao[A] with DonutInventoryService[A] {\n\n      override def add(donut: A): Long = {\n        println(s\"DonutShoppingCart-> add method -> donut: $donut\")\n        1\n      }\n\n      override def update(donut: A): Boolean = {\n        println(s\"DonutShoppingCart-> update method -> donut: $donut\")\n        true\n      }\n\n      override def search(donut: A): A = {\n        println(s\"DonutShoppingCart-> search method -> donut: $donut\")\n        donut\n      }\n\n      override def delete(donut: A): Boolean = {\n        println(s\"DonutShoppingCart-> delete method -> donut: $donut\")\n        true\n      }\n\n      override def checkStockQuantity(donut: A): Int = {\n        println(s\"DonutShoppingCart-> checkStockQuantity method -> donut: $donut\")\n        10\n      }\n    }\n\n\n    println(\"\\nStep 4: Create an instance of DonutShoppingCart and call the add, update, search and delete methods\")\n    val donutShoppingCart: DonutShoppingCart[String] = new DonutShoppingCart[String]()\n    donutShoppingCart.add(\"Vanilla Donut\")\n    donutShoppingCart.update(\"Vanilla Donut\")\n    donutShoppingCart.search(\"Vanilla Donut\")\n    donutShoppingCart.delete(\"Vanilla Donut\")\n\n\n    println(\"\\nStep 5: Call the checkStockQuantity method which was inherited from trait DonutInventoryService\")\n    donutShoppingCart.checkStockQuantity(\"Vanilla Donut\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/five/ExtendTrait_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.five\n\n/**\n  * /**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Extend Trait In Scala\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-5-traits/scala-extend-trait/]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\n  */\nobject ExtendTrait_Tutorial extends App {\n\n\n  println(\"Step 1: Create a trait which will define the methods for a data access layer\")\n  trait DonutShoppingCartDao {\n\n    def add(donutName: String): Long\n\n    def update(donutName: String): Boolean\n\n    def search(donutName: String): String\n\n    def delete(donutName: String): Boolean\n\n  }\n\n\n  println(\"\\nStep 2: Create a DonutShoppingCart class which extends the trait from Step 1 and implements its methods\")\n  class DonutShoppingCart extends DonutShoppingCartDao {\n\n    override def add(donutName: String): Long = {\n      println(s\"DonutShoppingCart-> add method -> donutName: $donutName\")\n      1\n    }\n\n    override def update(donutName: String): Boolean = {\n      println(s\"DonutShoppingCart-> update method -> donutName: $donutName\")\n      true\n    }\n\n    override def search(donutName: String): String = {\n      println(s\"DonutShoppingCart-> search method -> donutName: $donutName\")\n      donutName\n    }\n\n    override def delete(donutName: String): Boolean = {\n      println(s\"DonutShoppingCart-> delete method -> donutName: $donutName\")\n      true\n    }\n  }\n\n\n  println(\"\\nStep 3: Create an instance of DonutShoppingCart and call the add, update, search and delete methods\")\n  val donutShoppingCart1: DonutShoppingCart = new DonutShoppingCart()\n  donutShoppingCart1.add(\"Vanilla Donut\")\n  donutShoppingCart1.update(\"Vanilla Donut\")\n  donutShoppingCart1.search(\"Vanilla Donut\")\n  donutShoppingCart1.delete(\"Vanilla Donut\")\n\n\n\n  println(\"\\nStep 4: Create an instance of DonutShoppingCart and assign its type to the trait DonutShoppingCartDao\")\n  val donutShoppingCart2: DonutShoppingCartDao = new DonutShoppingCart()\n  donutShoppingCart2.add(\"Vanilla Donut\")\n  donutShoppingCart2.update(\"Vanilla Donut\")\n  donutShoppingCart2.search(\"Vanilla Donut\")\n  donutShoppingCart2.delete(\"Vanilla Donut\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/five/TraitDependencyInjectionPartTwo_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.five\n\n/**\n  * /**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Traits For Dependency Injection Part 2 - Avoid Cake Pattern\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-5-traits/scala-traits-depedency-injection-avoid-cake-pattern/]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\n  */\nobject TraitDependencyInjectionPartTwo_Tutorial extends App {\n\n  println(\"Step 1: How to define a class to encapsulate inventory services\")\n  class DonutInventoryService[T] {\n    def checkStock(donut: T): Boolean = {\n      println(\"DonutInventoryService->checkStock\")\n      true\n    }\n  }\n\n\n\n  println(\"\\nStep 2: How to define a class to encapsulate pricing services\")\n  class DonutPricingService[T] {\n    def calculatePrice(donut: T): Double = {\n      println(\"DonutPricingService->calculatePrice\")\n      2.50\n    }\n  }\n\n\n\n  println(\"\\nStep 3: How to define a class to encapsulate creating a donut order\")\n  class DonutOrderService[T] {\n    def createOrder(donut: T, quantity: Int, price: Double): Int = {\n      println(s\"Saving donut order to database: donut = $donut, quantity = $quantity, price = $price\")\n      100 // the id of the booked order\n    }\n  }\n\n\n\n  println(\"\\nStep 4: How to define a class to encapsulate shopping cart services\")\n  class DonutShoppingCartService[T] (\n    donutInventoryService: DonutInventoryService[T],\n    donutPricingService: DonutPricingService[T],\n    donutOrderService: DonutOrderService[T]) {\n\n    def bookOrder(donut: T, quantity: Int): Int = {\n      println(\"DonutShoppingCartService->bookOrder\")\n\n      donutInventoryService.checkStock(donut) match {\n        case true =>\n          val price = donutPricingService.calculatePrice(donut)\n          donutOrderService.createOrder(donut, quantity, price) // the id of the booked order\n\n        case false =>\n          println(s\"Sorry donut $donut is out of stock!\")\n          -100 // return some error code to identify out of stock\n      }\n    }\n  }\n\n\n\n  println(\"\\nStep 5: How to define a trait to encapsulate all the services for Donut store\")\n  trait DonutStoreServices {\n    val donutInventoryService = new DonutInventoryService[String]\n    val donutPricingService = new DonutPricingService[String]\n    val donutOrderService = new DonutOrderService[String]\n    val donutShoppingCartService = new DonutShoppingCartService(donutInventoryService, donutPricingService, donutOrderService)\n  }\n\n\n\n  println(\"\\nStep 6: How to define a facade to expose functionality of DonutStoreServices\")\n  trait DonutStoreAppController {\n    this: DonutStoreServices =>\n\n    def bookOrder(donut: String, quantity: Int): Int = {\n      println(\"DonutStoreAppController->bookOrder\")\n      donutShoppingCartService.bookOrder(donut, quantity)\n    }\n  }\n\n\n  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\")\n  object DonutStoreApp extends DonutStoreAppController with DonutStoreServices\n\n\n\n  println(\"\\nStep 8: How to call the bookOrder method of the Donut store app from Step 7\")\n  DonutStoreApp.bookOrder(\"Vanilla Donut\", 10)\n\n\n\n  println(\"\\nStep 9: Test DonutStoreApp by injecting a mocked version of DonutStoreServices\")\n  trait MockedDonutStoreServices extends DonutStoreServices {\n    override val donutInventoryService: DonutInventoryService[String] = ???\n    override val donutPricingService: DonutPricingService[String] = ???\n    override val donutOrderService: DonutOrderService[String] = ???\n    override val donutShoppingCartService: DonutShoppingCartService[String] = new DonutShoppingCartService[String](\n      donutInventoryService, donutPricingService, donutOrderService)\n  }\n\n\n\n  println(\"\\nStep 1: Create a Mocked Donut Store App and inject mocked donut services\")\n  object MockedDonutStoreApp extends DonutStoreAppController with MockedDonutStoreServices\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/five/TraitDependencyInjection_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.five\n\n/**\n  * /**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Traits For Dependency Injection\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-5-traits/scala-traits-depedency-injection/]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\n  */\nobject TraitDependencyInjection_Tutorial extends App {\n\n\n  println(\"Step 1: Create a trait which knows how to do create, read, update and delete operations CRUD to a given database\")\n  trait DonutDatabase[A] {\n\n    def addOrUpdate(donut: A): Long\n\n    def query(donut: A): A\n\n    def delete(donut: A): Boolean\n  }\n\n\n  println(\"\\nStep 2: Create a class which extends trait DonutDatabase and knows how to perform CRUD operations with Apache Cassandra as storage layer\")\n  class CassandraDonutStore[A] extends DonutDatabase[A] {\n\n    override def addOrUpdate(donut: A): Long = {\n      println(s\"CassandraDonutDatabase-> addOrUpdate method -> donut: $donut\")\n      1\n    }\n\n    override def query(donut: A): A = {\n      println(s\"CassandraDonutDatabase-> query method -> donut: $donut\")\n      donut\n    }\n\n    override def delete(donut: A): Boolean = {\n      println(s\"CassandraDonutDatabase-> delete method -> donut: $donut\")\n      true\n    }\n  }\n\n\n  println(\"\\nStep 3: Create a trait which will define the methods for a data access layer and will require dependency injection for DonutDatabase\")\n  trait DonutShoppingCartDao[A] {\n\n    val donutDatabase: DonutDatabase[A] // dependency injection\n\n    def add(donut: A): Long = {\n      println(s\"DonutShoppingCartDao-> add method -> donut: $donut\")\n      donutDatabase.addOrUpdate(donut)\n    }\n\n    def update(donut: A): Boolean = {\n      println(s\"DonutShoppingCartDao-> update method -> donut: $donut\")\n      donutDatabase.addOrUpdate(donut)\n      true\n    }\n\n    def search(donut: A): A = {\n      println(s\"DonutShoppingCartDao-> search method -> donut: $donut\")\n      donutDatabase.query(donut)\n    }\n\n    def delete(donut: A): Boolean = {\n      println(s\"DonutShoppingCartDao-> delete method -> donut: $donut\")\n      donutDatabase.delete(donut)\n    }\n\n  }\n\n\n\n  println(\"\\nStep 4: Create a trait which will define the methods for checking donut inventory and will require dependency injection for DonutDatabase\")\n  trait DonutInventoryService[A] {\n\n    val donutDatabase: DonutDatabase[A]  // dependency injection\n\n    def checkStockQuantity(donut: A): Int = {\n      println(s\"DonutInventoryService-> checkStockQuantity method -> donut: $donut\")\n      donutDatabase.query(donut)\n      1\n    }\n\n  }\n\n\n\n  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\")\n  trait DonutShoppingCartServices[A] extends DonutShoppingCartDao[A] with DonutInventoryService[A] {\n    override val donutDatabase: DonutDatabase[A] = new CassandraDonutStore[A]()\n  }\n\n\n\n  println(\"\\nStep 6: Create a DonutShoppingCart class which extends a single facade named DonutShoppingCartServices to expose all the underlying features required by a DonutShoppingCart\")\n  class DonutShoppingCart[A] extends DonutShoppingCartServices[A] {\n\n  }\n\n\n  println(\"\\nStep 7: Create an instance of DonutShoppingCart and call the add, update, search and delete methods\")\n  val donutShoppingCart: DonutShoppingCart[String] = new DonutShoppingCart[String]()\n  donutShoppingCart.add(\"Vanilla Donut\")\n  donutShoppingCart.update(\"Vanilla Donut\")\n  donutShoppingCart.search(\"Vanilla Donut\")\n  donutShoppingCart.delete(\"Vanilla Donut\")\n\n\n  println(\"\\nStep 8: Call the checkStockQuantity method\")\n  donutShoppingCart.checkStockQuantity(\"Vanilla Donut\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/five/TraitFactory_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.five\n\n/**\n  * /**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Traits, Companion Object, Factory Pattern\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-5-traits/scala-traits-companion-object-factory-pattern/]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\n  */\nobject TraitFactory_Tutorial extends App {\n\n\n  // Step 1: Define a wrapper object called Cakes to hold various types of cakes\n  object Cakes {\n\n    // Step 2: Define a base trait to represent a Cake\n    trait Cake {\n      def name: String\n    }\n\n    // Step 3: Define class implementations for the Cake trait namely: Cupcake, Donut and UnknownCake\n    class UnknownCake extends Cake {\n      override def name: String = \"Unknown Cake ... but still delicious!\"\n    }\n\n    class Cupcake extends Cake {\n      override def name: String = \"Cupcake\"\n    }\n\n    class Donut extends Cake {\n      override def name: String = \"Donut\"\n    }\n\n  }\n\n\n\n  // Step 4: Define a wrapper object called CakeFactory\")\n  object CakeFactory {\n    import Cakes._\n\n    // Step 5: Define an apply method which will act as a factory to produce the correct Cake implementation\n    def apply(cake: String): Cake = {\n      cake match {\n        case \"cupcake\" => new Cupcake\n        case \"donut\" => new Donut\n        case _ => new UnknownCake\n      }\n    }\n  }\n\n\n  // Step 6: Call the CakeFactory\n  println(s\"A cupcake = ${CakeFactory(\"cupcake\").name}\")\n  println(s\"A donut = ${CakeFactory(\"donut\").name}\")\n  println(s\"Unknown cake = ${CakeFactory(\"coconut tart\").name}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/five/TraitWithTypes_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.five\n\n/**\n  * /**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Traits With Type Paramters\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-5-traits/scala-trait-type-parameters/]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\n  */\nobject TraitWithTypes_Tutorial extends App {\n\n\n  println(\"Step 1: Create a trait with type which will define the methods for a data access layer\")\n  trait DonutShoppingCartDao[A] {\n\n    def add(donut: A): Long\n\n    def update(donut: A): Boolean\n\n    def search(donut: A): A\n\n    def delete(donut: A): Boolean\n\n  }\n\n\n  println(\"\\nStep 2: Create a DonutShoppingCart class of type A which extends the trait from Step 1 and implements its methods\")\n  class DonutShoppingCart[A] extends DonutShoppingCartDao[A] {\n\n    override def add(donut: A): Long = {\n      println(s\"DonutShoppingCart-> add method -> donut: $donut\")\n      1\n    }\n\n    override def update(donut: A): Boolean = {\n      println(s\"DonutShoppingCart-> update method -> donut: $donut\")\n      true\n    }\n\n    override def search(donut: A): A = {\n      println(s\"DonutShoppingCart-> search method -> donut: $donut\")\n      donut\n    }\n\n    override def delete(donut: A): Boolean = {\n      println(s\"DonutShoppingCart-> delete method -> donut: $donut\")\n      true\n    }\n  }\n\n\n  println(\"\\nStep 3: Create an instance of DonutShoppingCart of type String and call the add, update, search and delete methods\")\n  val donutShoppingCart1: DonutShoppingCart[String] = new DonutShoppingCart[String]()\n  donutShoppingCart1.add(\"Vanilla Donut\")\n  donutShoppingCart1.update(\"Vanilla Donut\")\n  donutShoppingCart1.search(\"Vanilla Donut\")\n  donutShoppingCart1.delete(\"Vanilla Donut\")\n\n\n\n  println(\"\\nStep 4: Create an instance of DonutShoppingCart of type String and assign its type to the trait DonutShoppingCartDao\")\n  val donutShoppingCart2: DonutShoppingCartDao[String] = new DonutShoppingCart[String]()\n  donutShoppingCart2.add(\"Vanilla Donut\")\n  donutShoppingCart2.update(\"Vanilla Donut\")\n  donutShoppingCart2.search(\"Vanilla Donut\")\n  donutShoppingCart2.delete(\"Vanilla Donut\")\n\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/CaseClassInheritance_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.four\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Extend Case Class - Case Class Inheritance\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-extend-case-class/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject CaseClassInheritance_Tutorial extends App {\n\n  println(\"Step 1: How to define an abstract class to represent a Donut object\")\n  abstract class Donut(name: String) {\n\n    def printName: Unit\n\n  }\n\n\n\n  println(\"\\nStep 2: How to extend the abstract class Donut and define a case class named VanillaDonut\")\n  case class VanillaDonut(name: String) extends Donut(name) {\n\n    override def printName: Unit = println(name)\n\n  }\n\n\n\n  println(\"\\nStep 3: How to extend the abstract class Donut and define a case class named VanillaDonut\")\n  case class GlazedDonut(name: String) extends Donut(name) {\n\n    override def printName: Unit = println(name)\n\n  }\n\n\n\n  println(\"\\nStep 4: How to instantiate Donut objects\")\n  val vanillaDonut: Donut = VanillaDonut(\"Vanilla Donut\")\n  vanillaDonut.printName\n\n  val glazedDonut: Donut = GlazedDonut(\"Glazed Donut\")\n  glazedDonut.printName\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/CaseClass_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.four\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Define And Use Case Class\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-define-use-case-class/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject CaseClass_Tutorial extends App {\n\n  println(\"Step 1: How to define a case class to represent a Donut object\")\n  case class Donut(name: String, price: Double, productCode: Option[Long] = None)\n\n\n\n  println(\"\\nStep 2: How to create instances or objects for the Donut case class\")\n  val vanillaDonut: Donut = Donut(\"Vanilla Donut\", 1.50)\n  val glazedDonut: Donut = Donut(\"Glazed Donut\", 2.0)\n  println(s\"Vanilla Donut = $vanillaDonut\")\n  println(s\"Glazed Donut = $glazedDonut\")\n\n\n\n  println(\"\\nStep 3: How to access fields of the Donut object\")\n  println(s\"Vanilla Donut name field = ${vanillaDonut.name}\")\n  println(s\"Vanilla Donut price field = ${vanillaDonut.price}\")\n  println(s\"Vanilla Donut productCode field = ${vanillaDonut.productCode}\")\n\n\n\n  println(\"\\nStep 4: How to modify or update fields of the Donut object\")\n  // vanillaDonut.name = \"vanilla donut\" // compiler error. fields are immutable by default.\n\n\n\n  println(\"\\nStep 5: How to define the hashCode and equals method for Donut object\")\n  val shoppingCart: Map[Donut, Int] = Map(vanillaDonut -> 4, glazedDonut -> 3)\n  println(s\"All items in shopping cart = ${shoppingCart}\")\n  println(s\"Quantity of vanilla donuts in shopping cart = ${shoppingCart(vanillaDonut)}\")\n  println(s\"Quantity of glazed donuts in shopping cart = ${shoppingCart(glazedDonut)}\")\n\n\n\n  println(\"\\nTIP: How to create a new object of Donut by using the copy() method of the case class\")\n  val chocolateVanillaDonut: Donut = vanillaDonut.copy(name = \"Chocolate And Vanilla Donut\", price = 5.0)\n  println(s\"Chocolate And Vanilla Donut = $chocolateVanillaDonut\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/CompanionObjectAsFactory_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.four\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Companion Objects' Apply Method As A Factory (Class Hierarchy Via Inheritance)\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-companion-objects-factory-apply-method-inheritance/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject CompanionObjectAsFactory_Tutorial extends App {\n\n  println(\"Step 1: How to define a simple class to represent a Donut object\")\n  class Donut(name: String, productCode: Option[Long] = None){\n\n    def print = println(s\"Donut name = $name, productCode = ${productCode.getOrElse(0)}\")\n\n  }\n\n\n\n  println(\"\\nStep 2: How to declare class hierarchy through inheritance using extends keyword\")\n  class GlazedDonut(name: String) extends Donut(name)\n\n  class VanillaDonut(name: String) extends Donut(name)\n\n\n\n  println(\"\\nStep 3: How to declare apply method of companion object as a factory\")\n  object Donut {\n\n    def apply(name: String): Donut = {\n      name match {\n        case \"Glazed Donut\" => new GlazedDonut(name)\n        case \"Vanilla Donut\" => new VanillaDonut(name)\n        case _ => new Donut(name)\n      }\n    }\n\n  }\n\n\n\n  println(\"\\nStep 4: How to call apply method of companion object which is a factory\")\n  val glazedDonut = Donut(\"Glazed Donut\")\n  println(s\"The class type of glazedDonut = ${glazedDonut.getClass}\")\n  glazedDonut.print\n\n  val vanillaDonut = Donut(\"Vanilla Donut\")\n  println(s\"The class type of vanillaDonut = ${vanillaDonut.getClass}\")\n  vanillaDonut.print\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/CompanionObjectFields_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.four\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Declare Values And Fields In Companion Object\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-declare-value-fields-companion-object/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject CompanionObjectFields_Tutorial extends App {\n\n\n  println(\"Step 1: How to define a simple class to represent a Donut object\")\n  class Donut(name: String, productCode: Option[Long] = None){\n\n    def print = println(s\"Donut name = $name, productCode = ${productCode.getOrElse(0)}, uuid = ${Donut.uuid}\")\n\n  }\n\n\n\n  println(\"\\nStep 2: How to declare fields and values in companion object\")\n  object Donut {\n\n    private val uuid = 1 // we've declared a uuid value and it is also marked as private.\n\n    def apply(name: String, productCode: Option[Long]): Donut = {\n      new Donut(name, productCode)\n    }\n\n    def apply(name: String): Donut = {\n      new Donut(name)\n    }\n  }\n\n\n\n  println(\"\\nStep 3: How to create instances of the Donut class using the companion object\")\n  val glazedDonut = Donut(\"Glazed Donut\", Some(1111))\n  val vanillaDonut = Donut(\"Vanilla Donut\")\n\n\n\n  println(\"\\nStep 4: How to call function on each Donut object\")\n  glazedDonut.print\n  vanillaDonut.print\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/CompanionObject_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.four\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create And Use Companion Objects\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-create-use-companion-objects/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject CompanionObject_Tutorial extends App {\n\n\n  println(\"Step 1: How to define a simple class to represent a Donut object\")\n  class Donut(name: String, productCode: Long){\n\n    def print = println(s\"Donut name = $name, productCode = $productCode\")\n\n  }\n\n\n\n  println(\"\\nStep 2: How to declare a companion object for the Donut class\")\n  object Donut {\n\n    def apply(name: String, productCode: Long): Donut = {\n      new Donut(name, productCode)\n    }\n\n  }\n\n\n\n  println(\"\\nStep 3: How to create instances of the Donut class using the companion object\")\n  val glazedDonut = Donut(\"Glazed Donut\", 1111)\n  val vanillaDonut = Donut(\"Vanilla Donut\", 2222)\n\n\n\n  println(\"\\nStep 4: How to call function on each Donut object\")\n  glazedDonut.print\n  vanillaDonut.print\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/ContraVariance_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.four\n\nimport com.allaboutscala.chapter.four.Covariance_Tutorial.{GlazedDonut, VanillaDonut}\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Contra-Variance Type Class\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-variance-contra-variance/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ContraVariance_Tutorial extends App {\n\n  println(\"Step 1: How to define an abstract class to represent a Donut object\")\n  abstract class Donut(name: String) {\n\n    def printName: Unit\n\n  }\n\n\n\n  println(\"\\nStep 2: How to extend the abstract class Donut and define a sub-class named VanillaDonut\")\n  case class VanillaDonut(name: String) extends Donut(name) {\n\n    override def printName: Unit = println(name)\n\n  }\n\n\n\n  println(\"\\nStep 3: How to extend the abstract class Donut and define a sub-class named VanillaDonut\")\n  case class GlazedDonut(name: String) extends Donut(name) {\n\n    override def printName: Unit = println(name)\n\n  }\n\n\n\n  println(\"\\nStep 4: How to create instances of Donut objects\")\n  val vanillaDonut: VanillaDonut = VanillaDonut(\"Vanilla Donut\")\n  vanillaDonut.printName\n\n  val glazedDonut: Donut = GlazedDonut(\"Glazed Donut\")\n  glazedDonut.printName\n\n\n\n  println(\"\\nStep 5: How to define a ShoppingCart type class which expects Donut types\")\n  class ShoppingCart[D <: Donut](donuts: Seq[D]) {\n\n    def printCartItems: Unit = donuts.foreach(_.printName)\n\n  }\n\n\n\n  println(\"\\nStep 6: How to create instances or objects of ShoppingCart class\")\n  val shoppingCart: ShoppingCart[Donut] = new ShoppingCart(Seq[Donut](vanillaDonut, glazedDonut))\n  shoppingCart.printCartItems\n\n\n\n  // Assume we want a shopping cart of just VanillaDonut and we want to inject Donut types\n  //  val shoppingCart: ShoppingCart[VanillaDonut] = new ShoppingCart[Donut](Seq(glazedDonut))\n  // NOTE: we get compiler error\n\n\n\n  println(s\"\\nStep 7: How to enable contra-variance on ShoppingCart\")\n  class ShoppingCart2[-D <: Donut](donuts: Seq[D]) {\n\n    def printCartItems: Unit = donuts.foreach(_.printName)\n\n  }\n\n  val shoppingCart2: ShoppingCart2[VanillaDonut] = new ShoppingCart2[Donut](Seq(glazedDonut))\n  shoppingCart2.printCartItems\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/Covariance_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.four\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Covariance Type Class\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-variance-covariance/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Covariance_Tutorial extends App {\n\n  println(\"Step 1: How to define an abstract class to represent a Donut object\")\n  abstract class Donut(name: String) {\n\n    def printName: Unit\n\n  }\n\n\n\n  println(\"\\nStep 2: How to extend the abstract class Donut and define a sub-class named VanillaDonut\")\n  case class VanillaDonut(name: String) extends Donut(name) {\n\n    override def printName: Unit = println(name)\n\n  }\n\n\n\n  println(\"\\nStep 3: How to extend the abstract class Donut and define a sub-class named VanillaDonut\")\n  case class GlazedDonut(name: String) extends Donut(name) {\n\n    override def printName: Unit = println(name)\n\n  }\n\n\n\n  println(\"\\nStep 4: How to create instances of Donut objects\")\n  val vanillaDonut: VanillaDonut = VanillaDonut(\"Vanilla Donut\")\n  vanillaDonut.printName\n\n  val glazedDonut: Donut = GlazedDonut(\"Glazed Donut\")\n  glazedDonut.printName\n\n\n\n  println(\"\\nStep 5: How to define a ShoppingCart type class which expects Donut types\")\n  class ShoppingCart[D <: Donut](donuts: Seq[D]) {\n\n    def printCartItems: Unit = donuts.foreach(_.printName)\n\n  }\n\n\n\n  println(\"\\nStep 6: How to create instances or objects of ShoppingCart class\")\n  val shoppingCart: ShoppingCart[Donut] = new ShoppingCart(Seq[Donut](vanillaDonut, glazedDonut))\n  shoppingCart.printCartItems\n\n\n\n  // Assume we want a shopping cart of just VanillaDonuts\n  //   val shoppingCart: ShoppingCart[Donut] = new ShoppingCart[VanillaDonut](Seq(vanillaDonut))\n  // NOTE: we get compiler error\n\n\n\n  println(s\"\\nStep 7: How to enable covariance on ShoppingCart\")\n  class ShoppingCart2[+D <: Donut](donuts: Seq[D]) {\n\n    def printCartItems: Unit = donuts.foreach(_.printName)\n\n  }\n\n  val shoppingCart2: ShoppingCart2[Donut] = new ShoppingCart2[VanillaDonut](Seq(vanillaDonut))\n  shoppingCart2.printCartItems\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/ExtendClass_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.four\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Extend Class - Class Inheritance\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-extend-class/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ExtendClass_Tutorial extends App {\n\n  println(\"Step 1: How to define an abstract class called Donut\")\n  abstract class Donut(name: String) {\n\n    def printName: Unit\n\n  }\n\n\n\n  println(\"\\nStep 2: How to extend abstract class Donut and define a sub-class of Donut called VanillaDonut\")\n  class VanillaDonut(name: String) extends Donut(name) {\n\n    override def printName: Unit = println(name)\n\n  }\n\n  object VanillaDonut {\n\n    def apply(name: String): Donut = {\n      new VanillaDonut(name)\n    }\n\n  }\n\n\n\n  println(\"\\nStep 3: How to extend abstract class Donut and define another sub-class of Donut called GlazedDonut\")\n  class GlazedDonut(name: String) extends Donut(name) {\n\n    override def printName: Unit = println(name)\n\n  }\n\n  object GlazedDonut {\n\n    def apply(name: String): Donut = {\n      new GlazedDonut(name)\n    }\n\n  }\n\n\n\n  println(\"\\nStep 4: How to instantiate Donut objects\")\n  val vanillaDonut: Donut = VanillaDonut(\"Vanilla Donut\")\n  vanillaDonut.printName\n\n  val glazedDonut: Donut = GlazedDonut(\"Glazed Donut\")\n  glazedDonut.printName\n\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/ImplicitClass_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.four\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Implicit Class - Extension Methods\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-use-implicit-class-extension-methods/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ImplicitClass_Tutorial extends App {\n\n  println(\"Step 1: How to define a case class to represent a Donut object\")\n  case class Donut(name: String, price: Double, productCode: Option[Long] = None)\n\n\n\n  println(\"\\nStep 2: How to create instances or objects for the Donut case class\")\n  val vanillaDonut: Donut = Donut(\"Vanilla\", 1.50)\n  println(s\"Vanilla donut name = ${vanillaDonut.name}\")\n  println(s\"Vanilla donut price = ${vanillaDonut.price}\")\n  println(s\"Vanilla donut produceCode = ${vanillaDonut.productCode}\")\n\n\n\n  println(\"\\nStep 3: How to define an implicit class to augment or extend the Donut object with a uuid field\")\n  object DonutImplicits{\n    implicit class AugmentedDonut(donut: Donut) {\n      def uuid: String = s\"${donut.name} - ${donut.productCode.getOrElse(12345)}\"\n    }\n  }\n\n\n\n  println(\"\\nStep 4: How to import and use the implicit class AugmentedDonut from Step 3\")\n  import DonutImplicits._\n  println(s\"Vanilla donut uuid = ${vanillaDonut.uuid}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/PackageObject_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.four\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Package Object\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-package-object/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject PackageObject_Tutorial extends App {\n\n  println(\"\\nStep 1: How to add JodaTime dependency in build.sbt\")\n  //  libraryDependencies ++= Seq(\n  //    \"joda-time\"     % \"joda-time\"     % \"2.9.3\",\n  //    \"org.joda\"      % \"joda-convert\"  % \"1.8\"\n  //  )\n\n\n\n  println(\"\\nStep 5: How to create instances or objects for the Donut case class from package object\")\n  val vanillaDonut: Donut = Donut(\"Vanilla\", 1.50)\n  println(s\"Vanilla donut name = ${vanillaDonut.name}\")\n  println(s\"Vanilla donut price = ${vanillaDonut.price}\")\n  println(s\"Vanilla donut produceCode = ${vanillaDonut.productCode}\")\n  println(s\"Vanilla donut uuid = ${vanillaDonut.uuid}\")\n\n\n\n  println(\"\\nStep 6: How to create new JodaTime instance using DateTime alias from package object\")\n  val today = new DateTime()\n  println(s\"today = $today, datetime class = ${today.getClass}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/SimpleClass_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.four\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Classes And Objects In Scala\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-create-classes-objects/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject SimpleClass_Tutorial extends App {\n\n  println(\"Step 1: How to define a simple class to represent a Donut object\")\n  class Donut(name: String, productCode: Long) {\n\n    def print = println(s\"Donut name = $name, productCode = $productCode\")\n\n  }\n\n  println(\"\\nStep 2: How to create instances of Donut class\")\n  val glazedDonut = new Donut(\"Glazed Donut\", 1111)\n  val vanillaDonut = new Donut(\"Vanilla Donut\", 2222)\n\n\n\n  println(\"\\nStep 3: How to call the print function for each of the donut object\")\n  glazedDonut.print\n  vanillaDonut.print\n\n\n\n  println(\"\\nStep 4: How to access the properties of class Donut\")\n// glazedDonut.name\n// glazedDonut.productCode\n  // NOTE:\n  // - You will get compiler error as we have not exposed the name and productCode properties using getters.\n  // - We will introduce Case Class in upcoming tutorials to automatically provide accessor methods.\n}\n\n\n\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/SingletonObject_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.four\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Declare And Use Singleton Object\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-declare-use-singleton-objects/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject SingletonObject_Tutorial extends App {\n\n\n  // Step 1: How to declare a Singleton Object\n  object DonutShoppingCartCalculator {\n\n    // Step 2: How to define a global field\n    val discount: Double = 0.01\n    // NOTE: In practice you won't assign a hard code value, but just showing how to declare global fields\n\n\n    // Step 3: How to define utility function called calculateTotalCost\n    def calculateTotalCost(donuts: List[String]): Double = {\n      // calculate the cost of donuts\n      return 1\n    }\n  }\n\n\n\n  println(\"\\nStep 4: How to call global discount field from Step 2\")\n  println(s\"Global discount = ${DonutShoppingCartCalculator.discount}\")\n\n\n\n  println(\"\\nStep 5: How to call the utility function calculateTotalCost from Step 3\")\n  println(s\"Call to calculateTotalCost function = ${DonutShoppingCartCalculator.calculateTotalCost(List())}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/TypeAlias_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.four\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Type Alias: Type Aliasing Versus Case Class\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-tutorial-learn-use-type-alias-versus-case-class/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject TypeAlias_Tutorial extends App {\n\n\n  println(\"Step 1: How to define a case class to represent a Donut object\")\n  case class Donut(name: String, price: Double, productCode: Option[Long] = None)\n\n\n\n  println(\"\\nStep 2: How to create instances or objects for the Donut case class\")\n  val vanillaDonut: Donut = Donut(\"Vanilla\", 1.50)\n  val glazedDonut: Donut = Donut(\"Glazed\", 2.0)\n  println(s\"Vanilla Donut = $vanillaDonut\")\n  println(s\"Glazed Donut = $glazedDonut\")\n\n\n\n  println(\"\\nStep 3: How to use type alias to name a Tuple2 pair into a domain type called CartItem\")\n  type CartItem[Donut, Int] = Tuple2[Donut, Int]\n\n\n\n  println(\"\\nStep 4: How to create instances of the aliased typed CartItem\")\n  val cartItem = new CartItem(vanillaDonut, 4)\n  println(s\"cartItem = $cartItem\")\n  println(s\"cartItem first value = ${cartItem._1}\")\n  println(s\"cartItem second value = ${cartItem._2}\")\n\n\n\n  println(\"\\nStep 5: How to use an aliased typed into a function parameter\")\n  def calculateTotal(shoppingCartItems: Seq[CartItem[Donut, Int]]): Double = {\n    // calculate the total cost\n    shoppingCartItems.foreach { cartItem =>\n      println(s\"CartItem donut = ${cartItem._1}, quantity = ${cartItem._2}\")\n    }\n    10 // some random total cost\n  }\n\n\n\n  println(\"\\nStep 6: How to use a case class instead of an aliased typed\")\n  case class ShoppingCartItem(donut: Donut, quantity: Int)\n\n  val shoppingItem: ShoppingCartItem = ShoppingCartItem(Donut(\"Glazed Donut\", 2.50), 10)\n  println(s\"shoppingItem donut = ${shoppingItem.donut}\")\n  println(s\"shoppingItem quantity = ${shoppingItem.quantity}\")\n\n\n\n  println(\"\\nStep 7: How to use case class from Step 6 to represent a Sequence of Donut items in a shopping cart\")\n  def calculateTotal2(shoppingCartItems: Seq[ShoppingCartItem]): Double = {\n    // calculate the total cost\n    shoppingCartItems.foreach { shoppingCartItem =>\n      println(s\"ShoppingCartItem donut = ${shoppingCartItem.donut}, quantity = ${shoppingCartItem.quantity}\")\n    }\n    10 // some random total cost\n  }\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/TypeClass_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.four\n\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Type Class\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-type-class/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject TypeClass_Tutorial extends App {\n\n  println(\"Step 1: How to define an abstract class to represent a Donut object\")\n  abstract class Donut(name: String) {\n\n    def printName: Unit\n\n  }\n\n\n\n  println(\"\\nStep 2: How to extend the abstract class Donut and define a sub-class named VanillaDonut\")\n  case class VanillaDonut(name: String) extends Donut(name) {\n\n    override def printName: Unit = println(name)\n\n  }\n\n\n\n  println(\"\\nStep 3: How to extend the abstract class Donut and define a sub-class named VanillaDonut\")\n  case class GlazedDonut(name: String) extends Donut(name) {\n\n    override def printName: Unit = println(name)\n\n  }\n\n\n\n  println(\"\\nStep 4: How to create instances of Donut objects\")\n  val vanillaDonut: VanillaDonut = VanillaDonut(\"Vanilla Donut\")\n  vanillaDonut.printName\n\n  val glazedDonut: Donut = GlazedDonut(\"Glazed Donut\")\n  glazedDonut.printName\n\n\n\n  println(\"\\nStep 5: How to define a ShoppingCart type class which expects Donut types\")\n  class ShoppingCart[D <: Donut](donuts: Seq[D]) {\n\n    def printCartItems: Unit = donuts.foreach(_.printName)\n\n  }\n\n\n\n  println(\"\\nStep 6: How to create instances or objects of ShoppingCart class\")\n  val shoppingCart: ShoppingCart[Donut] = new ShoppingCart(Seq[Donut](vanillaDonut, glazedDonut))\n  shoppingCart.printCartItems\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/four/package.scala",
    "content": "package com.allaboutscala.chapter\n\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Package Object\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-classes-scala/scala-package-object/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\npackage object four {\n\n  println(\"Step 2: How to define a case class to represent a Donut object in a package object\")\n  case class Donut(name: String, price: Double, productCode: Option[Long] = None)\n\n\n\n  println(\"\\nStep 3: How to define an implicit class to augment or extend the Donut object with a uuid field\")\n  implicit class AugmentedDonut(donut: Donut) {\n    def uuid: String = s\"${donut.name} - ${donut.productCode.getOrElse(12345)}\"\n  }\n\n\n\n  println(\"\\nStep 4: How to alias JodaTime to a DateTime type\")\n  type DateTime = org.joda.time.DateTime\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_01_Function_With_Future_Return_Type.scala",
    "content": "package com.allaboutscala.chapter.nine\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Method with future as return type\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#method-future-return-type Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_01_Function_With_Future_Return_Type extends App {\n\n  println(\"Step 1: Define a method which returns a Future\")\n  import scala.concurrent.Future\n  import scala.concurrent.ExecutionContext.Implicits.global\n  def donutStock(donut: String): Future[Int] = Future {\n    // assume some long running database operation\n    println(\"checking donut stock\")\n    10\n  }\n\n\n\n  println(\"\\nStep 2: Call method which returns a Future\")\n  import scala.concurrent.Await\n  import scala.concurrent.duration._\n  val vanillaDonutStock = Await.result(donutStock(\"vanilla donut\"), 5 seconds)\n  println(s\"Stock of vanilla donut = $vanillaDonutStock\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_02_Non_Blocking_Future_Result.scala",
    "content": "package com.allaboutscala.chapter.nine\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Non blocking future result\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#non-blocking-future-result Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_02_Non_Blocking_Future_Result extends App {\n\n\n  println(\"Step 1: Define a method which returns a Future\")\n  import scala.concurrent.Future\n  import scala.concurrent.ExecutionContext.Implicits.global\n  def donutStock(donut: String): Future[Int] = Future {\n    // assume some long running database operation\n    println(\"checking donut stock\")\n    10\n  }\n\n\n\n  println(\"\\nStep 2: Non blocking future result\")\n  import scala.util.{Failure, Success}\n  donutStock(\"vanilla donut\").onComplete {\n    case Success(stock) => println(s\"Stock for vanilla donut = $stock\")\n    case Failure(e) => println(s\"Failed to find vanilla donut stock, exception = $e\")\n  }\n  Thread.sleep(3000)\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_03_Chain_Futures_FlatMap.scala",
    "content": "package com.allaboutscala.chapter.nine\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Chain futures using flatMap\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#chain-futures-using-flatmap Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_03_Chain_Futures_FlatMap extends App {\n\n  println(\"Step 1: Define a method which returns a Future\")\n  import scala.concurrent.Future\n  import scala.concurrent.ExecutionContext.Implicits.global\n  def donutStock(donut: String): Future[Int] = Future {\n    // assume some long running database operation\n    println(\"checking donut stock\")\n    10\n  }\n\n\n\n  println(\"\\nStep 2: Define another method which returns a Future\")\n  def buyDonuts(quantity: Int): Future[Boolean] = Future {\n    println(s\"buying $quantity donuts\")\n    true\n  }\n\n\n\n  println(\"\\nStep 3: Chaining Futures using flatMap\")\n  val buyingDonuts: Future[Boolean] = donutStock(\"plain donut\").flatMap(qty => buyDonuts(qty))\n  import scala.concurrent.Await\n  import scala.concurrent.duration._\n  val isSuccess = Await.result(buyingDonuts, 5 seconds)\n  println(s\"Buying vanilla donut was successful = $isSuccess\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_04_Chain_Futures_For_Comprehension.scala",
    "content": "package com.allaboutscala.chapter.nine\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Chain futures using for comprehension\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#chain-futures-using-for-comprehension Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_04_Chain_Futures_For_Comprehension extends App {\n\n  println(\"Step 1: Define a method which returns a Future\")\n  import scala.concurrent.Future\n  import scala.concurrent.ExecutionContext.Implicits.global\n  def donutStock(donut: String): Future[Int] = Future {\n    // assume some long running database operation\n    println(\"checking donut stock\")\n    10\n  }\n\n\n\n  println(\"\\nStep 2: Define another method which returns a Future\")\n  def buyDonuts(quantity: Int): Future[Boolean] = Future {\n    println(s\"buying $quantity donuts\")\n    true\n  }\n\n\n\n  println(\"\\nStep 3: Chaining Futures using for comprehension\")\n  for {\n    stock     <- donutStock(\"vanilla donut\")\n    isSuccess <- buyDonuts(stock)\n  } yield println(s\"Buying vanilla donut was successful = $isSuccess\")\n\n  Thread.sleep(3000)\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_05_Future_Option_With_For_Comprehension.scala",
    "content": "package com.allaboutscala.chapter.nine\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Future option with for comprehension\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-option-with-for-comprehension Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_05_Future_Option_With_For_Comprehension extends App {\n\n  println(\"Step 1: Define a method which returns a Future Option\")\n  import scala.concurrent.Future\n  import scala.concurrent.ExecutionContext.Implicits.global\n  def donutStock(donut: String): Future[Option[Int]] = Future {\n    // assume some long running database operation\n    println(\"checking donut stock\")\n    if(donut == \"vanilla donut\") Some(10) else None\n  }\n\n\n\n  println(\"\\nStep 2: Define another method which returns a Future\")\n  def buyDonuts(quantity: Int): Future[Boolean] = Future {\n    println(s\"buying $quantity donuts\")\n    if(quantity > 0) true else false\n  }\n\n\n\n  println(\"\\nStep 3: Chaining Future Option using for comprehension\")\n  for {\n    someStock <- donutStock(\"vanilla donut\")\n    isSuccess <- buyDonuts(someStock.getOrElse(0))\n  } yield println(s\"Buying vanilla donut was successful = $isSuccess\")\n\n  Thread.sleep(3000)\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_06_Future_Option_Map.scala",
    "content": "package com.allaboutscala.chapter.nine\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Future option with map\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-option-with-map Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_06_Future_Option_Map extends App {\n\n  println(\"Step 1: Define a method which returns a Future Option\")\n  import scala.concurrent.Future\n  import scala.concurrent.ExecutionContext.Implicits.global\n  def donutStock(donut: String): Future[Option[Int]] = Future {\n    // assume some long running database operation\n    println(\"checking donut stock\")\n    if(donut == \"vanilla donut\") Some(10) else None\n  }\n\n\n\n  println(s\"\\nStep 2: Access value returned by future using map() method\")\n  donutStock(\"vanilla donut\")\n    .map(someQty => println(s\"Buying ${someQty.getOrElse(0)} vanilla donuts\"))\n\n  Thread.sleep(3000)\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_07_Composing_Futures.scala",
    "content": "package com.allaboutscala.chapter.nine\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Composing futures\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#composing-futures Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_07_Composing_Futures extends App {\n\n  println(\"Step 1: Define a method which returns a Future Option\")\n  import scala.concurrent.Future\n  import scala.concurrent.ExecutionContext.Implicits.global\n  def donutStock(donut: String): Future[Option[Int]] = Future {\n    // assume some long running database operation\n    println(\"checking donut stock\")\n    if(donut == \"vanilla donut\") Some(10) else None\n  }\n\n\n\n  println(\"\\nStep 2: Define another method which returns a Future\")\n  def buyDonuts(quantity: Int): Future[Boolean] = Future {\n    println(s\"buying $quantity donuts\")\n    if(quantity > 0) true else false\n  }\n\n\n\n  println(s\"\\nStep 3: Calling map() method over multiple futures\")\n  val resultFromMap: Future[Future[Boolean]] = donutStock(\"vanilla donut\")\n    .map(someQty => buyDonuts(someQty.getOrElse(0)))\n  Thread.sleep(1000)\n\n\n\n  println(s\"\\nStep 4: Calling flatMap() method over multiple futures\")\n  val resultFromFlatMap: Future[Boolean] = donutStock(\"vanilla donut\")\n    .flatMap(someQty => buyDonuts(someQty.getOrElse(0)))\n  Thread.sleep(1000)\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_08_Future_Sequence.scala",
    "content": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Failure, Success}\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Future sequence\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-sequence Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_08_Future_Sequence extends App {\n\n  println(\"Step 1: Define a method which returns a Future Option of Int\")\n  import scala.concurrent.ExecutionContext.Implicits.global\n  import scala.concurrent.Future\n  def donutStock(donut: String): Future[Option[Int]] = Future {\n    println(\"checking donut stock ... sleep for 2 seconds\")\n    Thread.sleep(2000)\n    if(donut == \"vanilla donut\") Some(10) else None\n  }\n\n\n\n  println(\"\\nStep 2: Define another method which returns a Future[Boolean]\")\n  def buyDonuts(quantity: Int): Future[Boolean] = Future {\n    println(s\"buying $quantity donuts ... sleep for 3 seconds\")\n    Thread.sleep(3000)\n    if(quantity > 0) true else false\n  }\n\n\n\n  println(\"\\nStep 3: Define another method for processing payments and returns a Future[Unit]\")\n  def processPayment(): Future[Unit] = Future {\n    println(\"processPayment ... sleep for 1 second\")\n    Thread.sleep(1000)\n  }\n\n\n\n  println(\"\\nStep 4: Combine future operations into a List\")\n  val futureOperations: List[Future[Any]] = List(donutStock(\"vanilla donut\"), buyDonuts(10), processPayment())\n\n\n\n  println(s\"\\nStep 5: Call Future.sequence to run the future operations in parallel\")\n  val futureSequenceResults = Future.sequence(futureOperations)\n  futureSequenceResults.onComplete {\n    case Success(results) => println(s\"Results $results\")\n    case Failure(e)       => println(s\"Error processing future operations, error = ${e.getMessage}\")\n  }\n\n  Thread.sleep(10000)\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_09_Future_Traverse.scala",
    "content": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Failure, Success}\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Future traverse\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-traverse Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_09_Future_Traverse extends App {\n\n  println(\"Step 1: Define a method which returns a Future Option\")\n  import scala.concurrent.Future\n  import scala.concurrent.ExecutionContext.Implicits.global\n  def donutStock(donut: String): Future[Option[Int]] = Future {\n    println(\"checking donut stock\")\n    if(donut == \"vanilla donut\") Some(10) else None\n  }\n\n\n  println(s\"\\nStep 2: Create a List of future operations\")\n  val futureOperations = List(\n    donutStock(\"vanilla donut\"),\n    donutStock(\"plain donut\"),\n    donutStock(\"chocolate donut\")\n  )\n\n\n\n  println(s\"\\nStep 3: Call Future.traverse to convert all Option of Int into Int\")\n  val futureTraverseResult = Future.traverse(futureOperations){ futureSomeQty =>\n    futureSomeQty.map(someQty => someQty.getOrElse(0))\n  }\n  futureTraverseResult.onComplete {\n    case Success(results) => println(s\"Results $results\")\n    case Failure(e)       => println(s\"Error processing future operations, error = ${e.getMessage}\")\n  }\n\n  Thread.sleep(3000)\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_10_Future_FoldLeft.scala",
    "content": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Success, Failure}\n\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Future foldLeft\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-foldLeft Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_10_Future_FoldLeft extends App {\n\n  println(\"Step 1: Define a method which returns a Future Option\")\n  import scala.concurrent.ExecutionContext.Implicits.global\n  import scala.concurrent.Future\n  def donutStock(donut: String): Future[Option[Int]] = Future {\n    println(\"checking donut stock\")\n    if(donut == \"vanilla donut\") Some(10) else None\n  }\n\n\n  println(s\"\\nStep 2: Create a List of future operations\")\n  val futureOperations = List(\n    donutStock(\"vanilla donut\"),\n    donutStock(\"plain donut\"),\n    donutStock(\"chocolate donut\"),\n    donutStock(\"vanilla donut\")\n  )\n\n\n  println(s\"\\nStep 3: Call Future.foldLeft to fold over futures results from left to right\")\n  val futureFoldLeft = Future.foldLeft(futureOperations)(0){ case (acc, someQty) =>\n    acc + someQty.getOrElse(0)\n  }\n  futureFoldLeft.onComplete {\n    case Success(results) => println(s\"Results $results\")\n    case Failure(e)       => println(s\"Error processing future operations, error = ${e.getMessage}\")\n  }\n\n  Thread.sleep(3000)\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_11_Future_Reduce.scala",
    "content": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Failure, Success}\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Future reduceLeft\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-reduceLeft Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_11_Future_Reduce extends App {\n\n\n  println(\"Step 1: Define a method which returns a Future Option\")\n  import scala.concurrent.ExecutionContext.Implicits.global\n  import scala.concurrent.Future\n  def donutStock(donut: String): Future[Option[Int]] = Future {\n    println(\"checking donut stock\")\n    if(donut == \"vanilla donut\") Some(10) else None\n  }\n\n\n  println(s\"\\nStep 2: Create a List of future operations\")\n  val futureOperations = List(\n    donutStock(\"vanilla donut\"),\n    donutStock(\"plain donut\"),\n    donutStock(\"chocolate donut\"),\n    donutStock(\"vanilla donut\")\n  )\n\n\n  println(s\"\\nStep 3: Call Future.reduceLeft to fold over futures results from left to right\")\n  val futureFoldLeft = Future.reduceLeft(futureOperations){ case (acc, someQty) =>\n    acc.map(qty => qty + someQty.getOrElse(0))\n  }\n  futureFoldLeft.onComplete {\n    case Success(results) => println(s\"Results $results\")\n    case Failure(e)       => println(s\"Error processing future operations, error = ${e.getMessage}\")\n  }\n\n  Thread.sleep(3000)\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_12_Future_FirstCompletedOf.scala",
    "content": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Success, Failure}\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Future firstCompletedOf\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-firstCompletedOf Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_12_Future_FirstCompletedOf extends App {\n\n  println(\"Step 1: Define a method which returns a Future Option\")\n  import scala.concurrent.ExecutionContext.Implicits.global\n  import scala.concurrent.Future\n  def donutStock(donut: String): Future[Option[Int]] = Future {\n    println(\"checking donut stock\")\n    if(donut == \"vanilla donut\") Some(10) else None\n  }\n\n\n\n  println(s\"\\nStep 2: Create a List of future operations\")\n  val futureOperations = List(\n    donutStock(\"vanilla donut\"),\n    donutStock(\"plain donut\"),\n    donutStock(\"chocolate donut\"),\n    donutStock(\"vanilla donut\")\n  )\n\n\n  println(s\"\\nStep 3: Call Future.firstCompletedOf to get the results of the first future that completes\")\n  val futureFirstCompletedResult = Future.firstCompletedOf(futureOperations)\n  futureFirstCompletedResult.onComplete {\n    case Success(results) => println(s\"Results $results\")\n    case Failure(e)       => println(s\"Error processing future operations, error = ${e.getMessage}\")\n  }\n\n  Thread.sleep(3000)\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_13_Future_Zip.scala",
    "content": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Success, Failure}\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Future zip\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-zip Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_13_Future_Zip extends App {\n\n  println(\"Step 1: Define a method which returns a Future Option\")\n  import scala.concurrent.ExecutionContext.Implicits.global\n  import scala.concurrent.Future\n  def donutStock(donut: String): Future[Option[Int]] = Future {\n    println(\"checking donut stock\")\n    if(donut == \"vanilla donut\") Some(10) else None\n  }\n\n\n\n  println(s\"\\nStep 2: Define a method which returns a Future Double for donut price\")\n  def donutPrice(): Future[Double] = Future.successful(3.25)\n\n\n\n  println(s\"\\nStep 3: Zip the values of the first future with the second future\")\n  val donutStockAndPriceOperation = donutStock(\"vanilla donut\") zip donutPrice()\n  donutStockAndPriceOperation.onComplete {\n    case Success(results) => println(s\"Results $results\")\n    case Failure(e)       => println(s\"Error processing future operations, error = ${e.getMessage}\")\n  }\n\n  Thread.sleep(3000)\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_14_Future_ZipWith.scala",
    "content": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Success, Failure}\n\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Future zipWith\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-zipWith Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_14_Future_ZipWith extends App {\n\n  println(\"Step 1: Define a method which returns a Future Option\")\n  import scala.concurrent.ExecutionContext.Implicits.global\n  import scala.concurrent.Future\n  def donutStock(donut: String): Future[Option[Int]] = Future {\n    println(\"checking donut stock\")\n    if(donut == \"vanilla donut\") Some(10) else None\n  }\n\n\n\n  println(s\"\\nStep 2: Define a method which returns a Future Double for donut price\")\n  def donutPrice(): Future[Double] = Future.successful(3.25)\n\n\n\n  println(s\"\\nStep 3: Define a value function to convert Tuple (Option[Int], Double) to Tuple (Int, Double)\")\n  val qtyAndPriceF: (Option[Int], Double) => (Int, Double) = (someQty, price) => (someQty.getOrElse(0), price)\n\n\n\n  println(s\"\\nStep 4: Call Future.zipWith and pass-through function qtyAndPriceF\")\n  val donutAndPriceOperation = donutStock(\"vanilla donut\").zipWith(donutPrice())(qtyAndPriceF)\n  donutAndPriceOperation.onComplete {\n    case Success(result) => println(s\"Result $result\")\n    case Failure(e)      => println(s\"Error processing future operations, error = ${e.getMessage}\")\n  }\n\n  Thread.sleep(3000)\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_15_Future_AndThen.scala",
    "content": "package com.allaboutscala.chapter.nine\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Future andThen\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-andThen Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_15_Future_AndThen extends App {\n\n  println(\"Step 1: Define a method which returns a Future\")\n  import scala.concurrent.Future\n  import scala.concurrent.ExecutionContext.Implicits.global\n  def donutStock(donut: String): Future[Int] = Future {\n    // assume some long running database operation\n    println(\"checking donut stock\")\n    10\n  }\n\n\n\n  println(s\"\\nStep 2: Call Future.andThen with a PartialFunction\")\n  val donutStockOperation = donutStock(\"vanilla donut\")\n  donutStockOperation.andThen { case stockQty => println(s\"Donut stock qty = $stockQty\")}\n\n  Thread.sleep(3000)\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_16_Future_Configure_ThreadPool.scala",
    "content": "package com.allaboutscala.chapter.nine\n\nimport java.util.concurrent.Executors\n\nimport scala.util.{Success, Failure}\n\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Future configure threadpool\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-configure-threadpool Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_16_Future_Configure_ThreadPool extends App {\n\n  // Tutorial name: how to configure your own thread pool for futures execution\n\n  println(\"Step 1: Define an ExecutionContext\")\n  val executor = Executors.newSingleThreadExecutor()\n  implicit val ec = scala.concurrent.ExecutionContext.fromExecutor(executor)\n\n\n\n  println(\"\\nStep 2: Define a method which returns a Future\")\n  import scala.concurrent.Future\n  def donutStock(donut: String): Future[Int] = Future {\n    // assume some long running database operation\n    println(\"checking donut stock\")\n    10\n  }\n\n\n\n  println(\"\\nStep 3: Call method which returns a Future\")\n  val donutStockOperation = donutStock(\"vanilla donut\")\n  donutStockOperation.onComplete {\n    case Success(donutStock)  => println(s\"Results $donutStock\")\n    case Failure(e)           => println(s\"Error processing future operations, error = ${e.getMessage}\")\n  }\n\n  Thread.sleep(3000)\n  executor.shutdownNow()\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_17_Future_Recover.scala",
    "content": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Failure, Success}\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Future recover\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-recover Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_17_Future_Recover extends App {\n\n  println(\"Step 1: Define a method which returns a Future\")\n  import scala.concurrent.ExecutionContext.Implicits.global\n  import scala.concurrent.Future\n  def donutStock(donut: String): Future[Int] = Future {\n    if(donut == \"vanilla donut\") 10\n    else throw new IllegalStateException(\"Out of stock\")\n  }\n\n\n\n  println(\"\\nStep 2: Execute donutStock() future operation\")\n  donutStock(\"vanilla donut\")\n    .onComplete {\n      case Success(donutStock)  => println(s\"Results $donutStock\")\n      case Failure(e)           => println(s\"Error processing future operations, error = ${e.getMessage}\")\n    }\n\n\n\n  println(\"\\nStep 3: Call Future.recover to recover from a known exception\")\n  donutStock(\"unknown donut\")\n    .recover { case e: IllegalStateException if e.getMessage == \"Out of stock\" => 0 }\n    .onComplete {\n      case Success(donutStock)  => println(s\"Results $donutStock\")\n      case Failure(e)           => println(s\"Error processing future operations, error = ${e.getMessage}\")\n    }\n\n  Thread.sleep(3000)\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_18_Future_RecoverWith.scala",
    "content": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Success, Failure}\n\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Future recoverWith\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-recoverWith Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_18_Future_RecoverWith extends App {\n\n  println(\"Step 1: Define a method which returns a Future\")\n  import scala.concurrent.ExecutionContext.Implicits.global\n  import scala.concurrent.Future\n  def donutStock(donut: String): Future[Int] = Future {\n    if(donut == \"vanilla donut\") 10\n    else throw new IllegalStateException(\"Out of stock\")\n  }\n\n\n\n  println(\"\\nStep 2: Execute donutStock() future operation\")\n  donutStock(\"vanilla donut\")\n    .onComplete {\n      case Success(donutStock)  => println(s\"Results $donutStock\")\n      case Failure(e)           => println(s\"Error processing future operations, error = ${e.getMessage}\")\n    }\n\n\n\n  println(\"\\nStep 3: Call Future.recoverWith to recover from a known exception\")\n  donutStock(\"unknown donut\")\n    .recoverWith { case e: IllegalStateException if e.getMessage == \"Out of stock\" => Future.successful(0) }\n    .onComplete {\n      case Success(donutStock)  => println(s\"Results $donutStock\")\n      case Failure(e)           => println(s\"Error processing future operations, error = ${e.getMessage}\")\n    }\n\n  Thread.sleep(3000)\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_19_Future_FallbackTo.scala",
    "content": "package com.allaboutscala.chapter.nine\n\nimport scala.util.{Failure, Success}\n\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Future fallbackTo\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-fallbackTo Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_19_Future_FallbackTo extends App {\n\n  println(\"Step 1: Define a method which returns a Future\")\n  import scala.concurrent.ExecutionContext.Implicits.global\n  import scala.concurrent.Future\n  def donutStock(donut: String): Future[Int] = Future {\n    if(donut == \"vanilla donut\") 10\n    else throw new IllegalStateException(\"Out of stock\")\n  }\n\n\n\n  println(\"\\nStep 2: Define another method which returns a Future to match a similar donut stock\")\n  def similarDonutStock(donut: String): Future[Int] = Future {\n    println(s\"replacing donut stock from a similar donut = $donut\")\n    if(donut == \"vanilla donut\") 20 else 5\n  }\n\n\n\n  println(\"\\nStep 3: Call Future.fallbackTo\")\n  val donutStockOperation = donutStock(\"plain donut\")\n    .fallbackTo(similarDonutStock(\"vanilla donut\"))\n    .onComplete {\n      case Success(donutStock)  => println(s\"Results $donutStock\")\n      case Failure(e)           => println(s\"Error processing future operations, error = ${e.getMessage}\")\n    }\n\n  Thread.sleep(3000)\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/nine/Tutorial_20_Future_Promise.scala",
    "content": "package com.allaboutscala.chapter.nine\n\nimport scala.concurrent.Promise\nimport scala.util.{Success, Try, Failure}\n\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Future promise\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-9-beginner-tutorial-using-scala-futures/#future-promise Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tutorial_20_Future_Promise extends App {\n\n  println(\"Step 1: Define a method which returns a Future\")\n  import scala.concurrent.ExecutionContext.Implicits.global\n  def donutStock(donut: String): Int = {\n    if(donut == \"vanilla donut\") 10\n    else throw new IllegalStateException(\"Out of stock\")\n  }\n\n\n  println(s\"\\nStep 2: Define a Promise of type Int\")\n  val donutStockPromise = Promise[Int]()\n\n\n\n  println(\"\\nStep 3: Define a future from Promise\")\n  val donutStockFuture = donutStockPromise.future\n  donutStockFuture.onComplete {\n    case Success(stock) => println(s\"Stock for vanilla donut = $stock\")\n    case Failure(e)     => println(s\"Failed to find vanilla donut stock, exception = $e\")\n  }\n\n\n\n  println(\"\\nStep 4: Use Promise.success or Promise.failure to control execution of your future\")\n  val donut = \"vanilla donut\"\n  if(donut == \"vanilla donut\") {\n    donutStockPromise.success(donutStock(donut))\n  } else {\n    donutStockPromise.failure(Try(donutStock(donut)).failed.get)\n  }\n\n\n\n  println(\"\\nStep 5: Completing Promise using Promise.complete() method\")\n  val donutStockPromise2 = Promise[Int]()\n  val donutStockFuture2 = donutStockPromise2.future\n  donutStockFuture2.onComplete {\n    case Success(stock) => println(s\"Stock for vanilla donut = $stock\")\n    case Failure(e)     => println(s\"Failed to find vanilla donut stock, exception = $e\")\n  }\n  donutStockPromise2.complete(Try(donutStock(\"unknown donut\")))\n\n  Thread.sleep(3000)\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/one/tutorial_04/HelloWorld.scala",
    "content": "package com.allaboutscala.chapter.one.tutorial_04\n\n/**\n  * Created by Nadim Bahadoor on 01/05/2016.\n  *\n  * Tutorial: Your first Scala Hello World application\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/scala-tutorial-first-hello-world-application/ Tutorial]]\n  *\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject HelloWorld extends App {\n\n  println(\"Hello World from Scala!\")\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/one/tutorial_05/HelloWorldMain.scala",
    "content": "package com.allaboutscala.chapter.one.tutorial_05\n\n/**\n  * Created by Nadim Bahadoor on 02/05/2016.\n  *\n  * Tutorial: Where is the main method to launch Scala application\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/where-is-main-method-launch-scala-application/ Tutorial]]\n  *\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject HelloWorldMain {\n\n  def main(args: Array[String]): Unit = {\n\n    println(\"Hello World from main function!\")\n  }\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/one/tutorial_06/HelloWorldWithArguments.scala",
    "content": "package com.allaboutscala.chapter.one.tutorial_06\n\n/**\n  * Created by Nadim Bahadoor on 03/05/2016.\n  *\n  * Tutorial: IntelliJ Run Configuration – Running Your Scala application\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/intellij-run-configuration-scala-application/ Tutorial]]\n  *\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject HelloWorldWithArguments extends App {\n\n\n  println(\"Hello World With Arguments Scala Application!\")\n\n\n  println(\"Command line arguments are: \")\n  println(args.mkString(\", \"))\n\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/one/tutorial_07/HelloWorldWithArgumentsDebug.scala",
    "content": "package com.allaboutscala.chapter.one.tutorial_07\n\n\n/**\n  * Created by Nadim Bahadoor on 05/05/2016.\n  *\n  * Tutorial: IntelliJ Debug Configuration – Debugging Your Scala Application\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/intellij-debug-configuration-scala-application/ Tutorial]]\n  *\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject HelloWorldWithArgumentsDebug extends App {\n\n  Console.println(\"Hello World With Arguments Scala Application!\")\n\n\n  Console.println(\"Command line arguments are: \")\n  Console.println(args.mkString(\", \"))\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/one/tutorial_10/HelloWorldWithScalaLogging.scala",
    "content": "package com.allaboutscala.chapter.one.tutorial_10\n\nimport com.typesafe.scalalogging.LazyLogging\n\n/**\n  * Created by Nadim Bahadoor on 06/05/2016.\n  *\n  * Tutorial: IntelliJ Import Dependencies – Getting Started With build.sbt\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-1-getting-familiar-intellij-ide/getting-started-sbt-import-dependencies-build-sbt/ Tutorial]]\n  *\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject HelloWorldWithScalaLogging extends App with LazyLogging {\n\n  logger.info(\"Hello World from Scala Logging\")\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableArrayBuffer_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.seven\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Mutable ArrayBuffer\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-arraybuffer/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject MutableArrayBuffer_Tutorial extends App {\n\n  import scala.collection.mutable.ArrayBuffer\n\n  println(\"Step 1: How to initialize an ArrayBuffer with 3 elements\")\n  val arrayBuffer1: ArrayBuffer[String] = ArrayBuffer(\"Plain Donut\",\"Strawberry Donut\",\"Chocolate Donut\")\n  println(s\"Elements of arrayBuffer1 = $arrayBuffer1\")\n\n\n\n  println(\"\\nStep 2: How to access elements of an ArrayBuffer at specific index\")\n  println(s\"Element at index 0 = ${arrayBuffer1(0)}\")\n  println(s\"Element at index 1 = ${arrayBuffer1(1)}\")\n  println(s\"Element at index 2 = ${arrayBuffer1(2)}\")\n\n\n\n  println(\"\\nStep 3: How to add elements to an ArrayBuffer using +=\")\n  arrayBuffer1 += \"Vanilla Donut\"\n  println(s\"Elements of arrayBuffer1 = $arrayBuffer1\")\n  // NOTE: arrayBuffer1 is mutable and hence we were able to add a new element to it\n\n\n\n  println(\"\\nStep 4: How to add elements from a List to an ArrayBuffer using ++=\")\n  arrayBuffer1 ++= List[String](\"Glazed Donut\", \"Krispy creme\")\n  println(s\"Elements of arrayBuffer1 = $arrayBuffer1\")\n\n\n\n  println(\"\\nStep 5: How to remove elements from an ArrayBuffer\")\n  arrayBuffer1 -= \"Plain Donut\"\n  println(s\"Elements of arrayBuffer1 = $arrayBuffer1\")\n\n\n\n  println(\"\\nStep 6: How to remove elements of a List from ArrayBuffer using --=\")\n  arrayBuffer1 --= List[String](\"Glazed Donut\", \"Krispy creme\")\n  println(s\"Elements of arrayBuffer1 = $arrayBuffer1\")\n\n\n\n  println(\"\\nStep 7: How to initialize an empty ArrayBuffer\")\n  val emptyArrayBuffer: ArrayBuffer[String] = ArrayBuffer.empty[String]\n  println(s\"Empty array buffer = $emptyArrayBuffer\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableArrayStack_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.seven\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Mutable ArrayStack\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-arraystack/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject MutableArrayStack_Tutorial extends App {\n\n  import scala.collection.mutable.ArrayStack\n  println(\"Step 1: How to initialize ArrayStack with 3 elements\")\n  val arrayStack1: ArrayStack[String] = ArrayStack(\"Plain Donut\", \"Strawberry Donut\", \"Chocolate Donut\")\n  println(s\"Elements of arrayStack1 = $arrayStack1\")\n\n\n  println(\"\\nStep 2: How to check elements at specific index of an ArrayStack\")\n  println(s\"Element at index 0 = ${arrayStack1(0)}\")\n  println(s\"Element at index 1 = ${arrayStack1(1)}\")\n  println(s\"Element at index 2 = ${arrayStack1(2)}\")\n\n\n  println(\"\\nStep 3: How to add elements to an ArrayStack using +=\")\n  arrayStack1 += \"Vanilla Donut\"\n  println(s\"Elements of arrayStack1 = $arrayStack1\")\n\n\n\n  println(\"\\nStep 4: How to add elements from a List to an ArrayStack using ++=\")\n  arrayStack1 ++= List[String](\"Glazed Donut\", \"Krispy creme\")\n  println(s\"Elements of arrayStack1 = $arrayStack1\")\n\n\n\n  println(\"\\nStep 5: How to take an element from an ArrayStack using pop function\")\n  println(s\"Pop element from stack  = ${arrayStack1.pop}\")\n  println(s\"Elements of arrayStack1 = $arrayStack1\")\n\n\n\n  println(\"\\nStep 6: How to push one element at the top of the ArrayStack using push function\")\n  arrayStack1.push(\"Krispy Creme\")\n  println(s\"Elements after push = $arrayStack1\")\n\n\n\n  println(\"\\nStep 7: How to initialize an empty ArrayStack\")\n  val emptyArrayStack: ArrayStack[Nothing] = ArrayStack.empty\n  println(s\"Empty Stack = $emptyArrayStack\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableArray_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.seven\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Mutable Array\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-array/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject MutableArray_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a String Array with 3 elements\")\n  val array1: Array[String] = Array(\"Plain Donut\",\"Strawberry Donut\",\"Chocolate Donut\")\n  println(s\"Elements of array1 = ${array1.mkString(\", \")}\")\n\n\n\n  println(\"\\nStep 2: How to access elements at specific index in an Array\")\n  println(s\"Element at index 0 = ${array1(0)}\")\n  println(s\"Element at index 1 = ${array1(1)}\")\n  println(s\"Element at index 2 = ${array1(2)}\")\n\n\n\n  println(\"\\nStep 3: How to initialize an Array by specifying it's capacity\")\n  val array2: Array[String] = new Array(3)\n  array2(0) = \"Plain Donut\"\n  array2(1) = \"Strawberry Donut\"\n  array2(2) = \"Chocolate Donut\"\n  println(s\"Elements of array2 = ${array2.mkString(\", \")}\")\n\n\n\n  println(\"\\nStep 4: How to create a 2D Array (2 dimension array)\")\n  val rows = 2\n  val columns = 2\n  val array3: Array[Array[String]] = Array.ofDim[String](rows,columns)\n  array3(0)(0) = \"Plain\"\n  array3(0)(1) = \"Donut\"\n  array3(1)(0) = \"Strawberry\"\n  array3(1)(1) = \"Donut\"\n  println(s\"Elements of 2 dimensional array = ${array3.deep.toList}\")\n\n\n\n  println(\"\\nStep 5: How to create 3D Array (3 Dimension Array) using Array.ofDim() method\")\n  val array4: Array[Array[String]] = Array.ofDim[String](3,3)\n  println(s\"Elements of 3 dimensional array = ${array4.deep.toList}\")\n\n\n\n  println(\"\\nStep 6: How to create an Array using tabulate function\")\n  val array5: Array[Int] = Array.tabulate(5)(_ + 1)\n  println(s\"Array of 5 columns = ${array5.toList}\")\n\n\n\n  println(\"\\nStep 7: How to create dimensional Arrays using tabulate function\")\n  val row1 = 1\n  val column3 = 3\n  val arrayOfOneRowAndThreeColumns = Array.tabulate(row1, column3)( (row, column) => row + column )\n  println(s\"Array with 1 row and 3 columns = ${arrayOfOneRowAndThreeColumns.deep.toString}\")\n\n  val row2 = 2\n  val arrayOfTowRowsAndThreeColumns = Array.tabulate(row2, column3)( (row, column) => row + column )\n  println(s\"Array with 2 rows and 3 columns = ${arrayOfTowRowsAndThreeColumns.deep.toString}\")\n\n  val row3 = 3\n  val arrayOfThreeRowsAndThreeColumns = Array.tabulate(row3, column3)( (row, column) => row + column )\n  println(s\"Array with 3 rows and 3 columns = ${arrayOfTowRowsAndThreeColumns.deep.toString}\")\n\n\n\n  println(\"\\nStep 8: How to create Array using Range\")\n  val rangeArray: Array[Int] = (1 to 10).toArray[Int]\n  println(s\"Array using Range from 1 to 10 = ${rangeArray.mkString(\", \")}\")\n\n\n\n  println(\"\\nStep 9: How to copy an Array using Array.copy\")\n  val copyOfRangeArray: Array[Int] = new Array(rangeArray.size)\n  Array.copy(rangeArray, 0, copyOfRangeArray, 0, rangeArray.size)\n  println(s\"copy of range array with elements from rangeArray = ${copyOfRangeArray.mkString(\", \")}\")\n\n\n\n  println(\"\\nStep 10: How to clone an Array\")\n  val clonedRangeArray = rangeArray.clone\n  clonedRangeArray(0) = 10 // update index 0 to value 10\n  println(s\"clonedRangeArray = ${clonedRangeArray.mkString(\", \")}\")\n  println(s\"original range array still unchanged = ${rangeArray.mkString(\", \")}\")\n\n\n\n  println(\"\\nStep 11: How to iterate over an Array using for comprehension\")\n  for(d <- array1){\n    println(s\"d = $d\")\n  }\n\n\n\n  println(\"\\nStep 12: How to merge two Arrays using Array.concat\")\n  val moreDonutsArray: Array[String] = Array(\"Vanilla Donut\",\"Glazed Donut\")\n  val mergedDonutArray: Array[String] = Array.concat(array1, moreDonutsArray)\n  println(s\"Merged Array of donuts = ${mergedDonutArray.mkString(\", \")}\")\n\n\n\n  println(\"\\nStep 13: How to check if two Arrays are equal\")\n  val arrayToCompare = Array[String](\"Plain Donut\",\"Strawberry Donut\",\"Chocolate Donut\")\n\n  println(s\"using == ${array1 == moreDonutsArray}\") // prints false\n\n  println(s\"using == ${array1 == arrayToCompare}\") // ALSO prints false ??? what ... be careful\n\n  println(s\"using sameElement function = ${array1 sameElements arrayToCompare}\") // NOW this works and returns true!\n\n\n\n  println(\"\\nStep 14: How to check if two Arrays are equal using deep function and == \")\n  println(s\"using deep function = ${array1.deep == arrayToCompare.deep}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableBitSet_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.seven\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Mutable BitSet\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-bitset/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject MutableBitSet_Tutorial extends App {\n\n  import scala.collection.mutable.BitSet\n  println(\"\\nStep 1: How to initialize a BitSet\")\n  val bitSet1: BitSet = BitSet(0, 2, 4, 6, 8)\n  println(s\"Elements of bitSet1 = $bitSet1\")\n\n\n\n  println(\"\\nStep 2: How to check specific elements in BitSet\")\n  println(s\"Element 0 = ${bitSet1(0)}\")\n  println(s\"Element 1 = ${bitSet1(1)}\")\n  println(s\"Element 2 = ${bitSet1(2)}\")\n\n\n\n  println(\"\\nStep 3: How to add elements to BitSet using +=\")\n  bitSet1 += 10\n  println(s\"Elements of bitSet1 after adding element 10 = $bitSet1\")\n\n\n\n  println(\"\\nStep 4: How to add two BitSets together using ++=\")\n  bitSet1 ++= BitSet(12, 14, 16, 18, 20)\n  println(s\"Elements of bitSet1 after adding second BitSet = $bitSet1\")\n\n\n\n  println(\"\\nStep 5: How to remove element from BitSet using -=\")\n  bitSet1 -= 0\n  println(s\"bitSet1 without element 0 = $bitSet1\")\n\n\n\n  println(\"\\nStep 6: How to find the intersection between two BitSets using &\")\n  val bitSetEven2: BitSet = BitSet(6, 8, 10)\n  println(s\"Intersection of bitSet1 and bitSetEven2 = ${bitSet1 & bitSetEven2}\")\n\n\n\n  println(\"\\nStep 7: How to find the difference between two BitSets using &~\")\n  println(s\"Difference of bitSet1 and bitSetEven2 = ${bitSet1 &~ bitSetEven2}\")\n\n\n\n  println(\"\\nStep 8: How to initialize an empty BitSet\")\n  val emptyBitSet: BitSet = BitSet.empty\n  println(s\"Empty BitSet = $emptyBitSet\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableHashMap_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.seven\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Mutable HashMap\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-hashmap/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject MutableHashMap_Tutorial extends App {\n\n  import scala.collection.mutable.HashMap\n  println(\"\\nStep 1: How to initialize a HashMap with 3 elements\")\n  val hashMap1: HashMap[String, String] = HashMap((\"PD\",\"Plain Donut\"),(\"SD\",\"Strawberry Donut\"),(\"CD\",\"Chocolate Donut\"))\n  println(s\"Elements of hashMap1 = $hashMap1\")\n\n\n  println(\"\\nStep 2: How to initialize HashMap using key -> value notation\")\n  val hashMap2: HashMap[String, String] = HashMap(\"VD\"-> \"Vanilla Donut\", \"GD\" -> \"Glazed Donut\")\n  println(s\"Elements of hashMap2 = $hashMap2\")\n\n\n  println(\"\\nStep 3: How to access elements of HashMap by specific key\")\n  println(s\"Element by key VD = ${hashMap2(\"VD\")}\")\n  println(s\"Element by key GD = ${hashMap2(\"GD\")}\")\n\n\n  println(\"\\nStep 4: How to add elements to HashMap using +=\")\n  hashMap1 += (\"KD\" -> \"Krispy Kreme Donut\")\n  println(s\"Element in hashMap1 = $hashMap1\")\n\n\n\n  println(\"\\nStep 5: How to add elements from a HashMap to an existing HashMap using ++=\")\n  hashMap1 ++= hashMap2\n  println(s\"Elements in hashMap1 = $hashMap1\")\n\n\n\n  println(\"\\nStep 6: How to remove key and its value from HashMap using -=\")\n  hashMap1 -= \"CD\"\n  println(s\"HashMap without the key CD and its value = $hashMap1\")\n\n\n\n  println(\"\\nStep 7: How to initialize an empty HashMap\")\n  val emptyMap: HashMap[String,String] = HashMap.empty[String,String]\n  println(s\"Empty HashMap = $emptyMap\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableHashSet_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.seven\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Mutable HashSet\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-hashset/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject MutableHashSet_Tutorial extends App {\n\n  import scala.collection.mutable.HashSet\n  println(\"\\nStep 1: How to initialize a HashSet with 3 elements\")\n  val hashSet1: HashSet[String] = HashSet(\"Plain Donut\",\"Strawberry Donut\",\"Chocolate Donut\")\n  println(s\"Elements of hashSet1 = $hashSet1\")\n\n\n\n  println(\"\\nStep 2: How to check specific elements in HashSet\")\n  println(s\"Element Plain Donut = ${hashSet1(\"Plain Donut\")}\")\n  println(s\"Element Strawberry Donut = ${hashSet1(\"Strawberry Donut\")}\")\n  println(s\"Element Chocolate Donut = ${hashSet1(\"Chocolate Donut\")}\")\n\n\n\n  println(\"\\nStep 3: How to add elements to HashSet using +=\")\n  hashSet1 += \"Vanilla Donut\"\n  println(s\"Elements of hashSet1 after adding Vanilla Donut element = $hashSet1\")\n\n\n\n  println(\"\\nStep 4: How to add two HashSets together using ++=\")\n  hashSet1 ++= HashSet[String](\"Vanilla Donut\", \"Glazed Donut\")\n  println(s\"Elements of hashSet1 after adding another HashSet = $hashSet1\")\n\n\n\n  println(\"\\nStep 5: How to remove element from HashSet using -=\")\n  hashSet1 -= \"Plain Donut\"\n  println(s\"HashSet without Plain Donut element = $hashSet1\")\n\n\n\n  println(\"\\nStep 6: How to find the intersection between two HashSets using &\")\n  val hashSet2: HashSet[String] = HashSet(\"Vanilla Donut\", \"Glazed Donut\", \"Plain Donut\")\n  println(s\"Intersection of hashSet1 and hashSet2 = ${hashSet1 & hashSet2}\")\n\n\n\n  println(\"\\nStep 7: How to find the difference between two HashSets using &~\")\n  println(s\"Difference of hashSet1 and hashSet5 = ${hashSet1 &~ hashSet2}\")\n\n\n\n  println(\"\\nStep 8: How to initialize an empty HashSet\")\n  val emptyHashSet: HashSet[String] = HashSet.empty[String]\n  println(s\"Empty HashSet = $emptyHashSet\")\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableLinkedHashMap_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.seven\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Mutable LinkedHashMap\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-linkedhashmap/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject MutableLinkedHashMap_Tutorial extends App {\n\n\n  import scala.collection.mutable.LinkedHashMap\n  println(\"\\nStep 1: How to initialize a LinkedHashMap with 3 elements\")\n  val linkedHashMap1: LinkedHashMap[String, String] = LinkedHashMap(\"PD\" -> \"Plain Donut\", \"SD\" ->\"Strawberry Donut\", \"CD\" -> \"Chocolate Donut\")\n  println(s\"Elements of linkedHashMap1 = $linkedHashMap1\")\n\n\n\n  println(\"\\nStep 2: How to initialize a LinkedHashMap using key -> value notation\")\n  val linkedHashMap2: LinkedHashMap[String, String] = LinkedHashMap(\"VD\"-> \"Vanilla Donut\", \"GD\" -> \"Glazed Donut\")\n  println(s\"LinkedHashMap1 = $linkedHashMap2\")\n\n\n\n  println(\"\\nStep 3: How to access elements of LinkedHashMap by specific key\")\n  println(s\"Element by key VD = ${linkedHashMap2(\"VD\")}\")\n  println(s\"Element by key GD = ${linkedHashMap2(\"GD\")}\")\n\n\n\n  println(\"\\nStep 4: How to add elements to LinkedHashMap using +=\")\n  linkedHashMap1 += (\"KD\" -> \"Krispy Kreme Donut\")\n  println(s\"Elements of linkedHashMap1 = ${linkedHashMap1}\")\n\n\n\n  println(\"\\nStep 5: How to add elements from a LinkedHashMap to an existing LinkedHashMap using ++=\")\n  linkedHashMap1 ++= linkedHashMap2\n  println(s\"Elements of linkedHashMap1 = ${linkedHashMap1}\")\n\n\n\n  println(\"\\nStep 6: How to remove key and its value from LinkedHashMap using -=\")\n  linkedHashMap1 -= (\"CD\")\n  println(s\"LinkedHashMap without the key CD and its value = $linkedHashMap1\")\n\n\n\n  println(\"\\nStep 7: How to initialize an empty LinkedHashMap\")\n  val emptyLinkedHashMap: LinkedHashMap[String, String] = LinkedHashMap.empty[String,String]\n  println(s\"Empty LinkedHashMap of type String = $emptyLinkedHashMap\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableLinkedHashSet_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.seven\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Mutable LinkedHashSet\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-linkedhashset/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject MutableLinkedHashSet_Tutorial extends App {\n\n\n  import scala.collection.mutable.LinkedHashSet\n  println(\"\\nStep 1: How to initialize a LinkedHashSet with 3 elements\")\n  val linkedHashSet1: LinkedHashSet[String] = LinkedHashSet(\"Plain Donut\",\"Strawberry Donut\",\"Chocolate Donut\")\n  println(s\"Elements of linkedHashSet1 = $linkedHashSet1\")\n\n\n\n  println(\"\\nStep 2: How to check specific elements in LinkedHashSet\")\n  println(s\"Element Plain Donut = ${linkedHashSet1(\"Plain Donut\")}\")\n  println(s\"Element Strawberry Donut = ${linkedHashSet1(\"Strawberry Donut\")}\")\n  println(s\"Element Chocolate Donut = ${linkedHashSet1(\"Chocolate Donut\")}\")\n\n\n\n  println(\"\\nStep 3: How to add elements to LinkedHashSet using +=\")\n  linkedHashSet1 += \"Vanilla Donut\"\n  println(s\"Elements of linkedHashSet1 after adding Vanilla Donut element = $linkedHashSet1\")\n\n\n\n  println(\"\\nStep 4: How to add two LinkedHashSets together using ++=\")\n  linkedHashSet1 ++= LinkedHashSet[String](\"Vanilla Donut\", \"Glazed Donut\")\n  println(s\"Elements of linkedHashSet1 after adding another HashSet = $linkedHashSet1\")\n\n\n\n  println(\"\\nStep 5: How to remove element from LinkedHashSet using -=\")\n  linkedHashSet1 -= \"Plain Donut\"\n  println(s\"Set without Plain Donut element = $linkedHashSet1\")\n\n\n\n  println(\"\\nStep 6: How to find the intersection between two LinkedHashSets using &\")\n  val linkedHashSet2: LinkedHashSet[String] = LinkedHashSet(\"Vanilla Donut\", \"Glazed Donut\", \"Plain Donut\")\n  println(s\"Intersection of linkedHashSet1 and linkedHashSet2 = ${linkedHashSet1 & linkedHashSet2}\")\n\n\n\n  println(\"\\nStep 7: How to find the difference between two LinkedHashSets using &~\")\n  println(s\"Difference of linkedHashSet1 and linkedHashSet2 = ${linkedHashSet1 &~ linkedHashSet2}\")\n\n\n\n  println(\"\\nStep 8: How to initialize an empty LinkedHashSet\")\n  val emptyLinkedHashSet: LinkedHashSet[String] = LinkedHashSet.empty[String]\n  println(s\"Empty LinkedHashSet = $emptyLinkedHashSet\")\n\n\n\n  println(\"\\nStep 9: How to print elements in order inserted to LinkedHashSet using foreach function\")\n  val linkedHashSet3: LinkedHashSet[String] = LinkedHashSet.empty[String]\n  linkedHashSet3 += \"Vanilla Donut\"\n  linkedHashSet3 += \"Glazed Donut\"\n  linkedHashSet3 += \"Plain Donut\"\n  linkedHashSet3 += \"Chocolate Donut\"\n  linkedHashSet3.foreach(donut => println(s\"$donut\"))\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableListBuffer_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.seven\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Mutable ListBuffer\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-listbuffer/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject MutableListBuffer_Tutorial extends App {\n\n  import scala.collection.mutable.ListBuffer\n  println(\"Step 1: How to initialize a ListBuffer with 3 elements\")\n  val listBuffer1: ListBuffer[String] = ListBuffer(\"Plain Donut\",\"Strawberry Donut\",\"Chocolate Donut\")\n  println(s\"Elements of listBuffer1 = $listBuffer1\")\n\n\n\n  println(\"\\nStep 2: How to access elements at specific index in a ListBuffer\")\n  println(s\"Element at index 0 = ${listBuffer1(0)}\")\n  println(s\"Element at index 1 = ${listBuffer1(1)}\")\n  println(s\"Element at index 2 = ${listBuffer1(2)}\")\n\n\n\n  println(\"\\nStep 3: How to add elements to a ListBuffer using +=\")\n  listBuffer1 += \"Vanilla Donut\"\n  println(s\"Elements of listBuffer1 = $listBuffer1\")\n\n\n\n  println(\"\\nStep 4: How to add elements from a List to a ListBuffer using ++=\")\n  listBuffer1 ++= List[String](\"Glazed Donut\", \"Krispy creme\")\n  println(s\"Elements of listBuffer1 = $listBuffer1\")\n\n\n\n  println(\"\\nStep 5: How to remove elements from a ListBuffer\")\n  listBuffer1 -= \"Plain Donut\"\n  println(s\"Elements of listBuffer1 = $listBuffer1\")\n\n\n\n  println(\"\\nStep 6: How to remove elements from a List to a ListBuffer using --=\")\n  listBuffer1 --= List[String](\"Glazed Donut\", \"Krispy creme\")\n  println(s\"Elements of listBuffer1 = $listBuffer1\")\n\n\n\n  println(\"\\nStep 7: How to initialize an empty ListBuffer\")\n  val emptyListBuffer: ListBuffer[String] = ListBuffer.empty[String]\n  println(s\"Empty list buffer = $emptyListBuffer\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableListMap_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.seven\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Mutable ListMap\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-listmap/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject MutableListMap_Tutorial extends App {\n\n  import scala.collection.mutable.ListMap\n  println(\"\\nStep 1: How to initialize a ListMap with 3 elements\")\n  val listMap1: ListMap[String, String] = ListMap(\"PD\" -> \"Plain Donut\", \"SD\" ->\"Strawberry Donut\", \"CD\" -> \"Chocolate Donut\")\n  println(s\"Elements of listMap1 = $listMap1\")\n\n\n\n  println(\"\\nStep 2: How to initialize ListMap using key -> value notation\")\n  val listMap2: ListMap[String, String] = ListMap(\"VD\"-> \"Vanilla Donut\", \"GD\" -> \"Glazed Donut\")\n  println(s\"Elements of listMap1 = $listMap2\")\n\n\n\n  println(\"\\nStep 3: How to access elements of ListMap by specific key\")\n  println(s\"Element by key VD = ${listMap2(\"VD\")}\")\n  println(s\"Element by key GD = ${listMap2(\"GD\")}\")\n\n\n\n  println(\"\\nStep 4: How to add elements to ListMap using +=\")\n  listMap1 += (\"KD\" -> \"Krispy Kreme Donut\")\n  println(s\"Element of listMap1 = ${listMap1}\")\n\n\n\n  println(\"\\nStep 5: How to add elements from a ListMap to an existing ListMap using ++=\")\n  listMap1 ++= listMap2\n  println(s\"Element of listMap1 = ${listMap1}\")\n\n\n\n  println(\"\\nStep 6: How to remove key and its value from ListMap using -=\")\n  listMap1 -= (\"CD\")\n  println(s\"ListMap without the key CD and its value = $listMap1\")\n\n\n\n  println(\"\\nStep 7: How to initialize an empty ListMap\")\n  val emptyListMap: ListMap[String, String] = ListMap.empty[String,String]\n  println(s\"Empty ListMap of type String = $emptyListMap\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableMap_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.seven\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Mutable Map\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-map/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject MutableMap_Tutorial extends App {\n\n  import scala.collection.mutable.Map\n  println(\"\\nStep 1: How to initialize a Map with 3 elements\")\n  val map1: Map[String, String] = Map((\"PD\",\"Plain Donut\"),(\"SD\",\"Strawberry Donut\"),(\"CD\",\"Chocolate Donut\"))\n  println(s\"Elements of map1 = $map1\")\n\n\n  println(\"\\nStep 2: How to initialize a Map using key -> value notation\")\n  val map2: Map[String, String] = Map(\"VD\"-> \"Vanilla Donut\", \"GD\" -> \"Glazed Donut\")\n  println(s\"Elements of map2 = $map2\")\n\n\n  println(\"\\nStep 3: How to access elements of Map by specific key\")\n  println(s\"Element by key VD = ${map2(\"VD\")}\")\n  println(s\"Element by key GD = ${map2(\"GD\")}\")\n\n\n  println(\"\\nStep 4: How to add elements to Map using +=\")\n  map1 += (\"KD\" -> \"Krispy Kreme Donut\")\n  println(s\"Element in map1 = $map1\")\n\n\n\n  println(\"\\nStep 5: How to add elements from a Map to an existing Map using ++=\")\n  map1 ++= map2\n  println(s\"Elements in map1 = $map1\")\n\n\n  println(\"\\nStep 6: How to remove key and its value from Map using -=\")\n  map1 -= \"CD\"\n  println(s\"Map without the key CD and its value = $map1\")\n\n\n  println(\"\\nStep 7: How to initialize an empty Map\")\n  val emptyMap: Map[String,String] = Map.empty[String,String]\n  println(s\"Empty Map = $emptyMap\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableQueue_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.seven\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Mutable Queue\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-queue/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject MutableQueue_Tutorial extends App {\n\n  import scala.collection.mutable.Queue\n  println(\"\\nStep 1: How to initialize a Queue with 3 elements\")\n  val queue1: Queue[String] = Queue(\"Plain Donut\", \"Strawberry Donut\", \"Chocolate Donut\")\n  println(s\"Elements of queue1 = $queue1\")\n\n\n\n  println(\"\\nStep 2: How to access elements of Queue at specific index\")\n  println(s\"Element at index 0 = ${queue1(0)}\")\n  println(s\"Element at index 0 = ${queue1(1)}\")\n  println(s\"Element at index 0 = ${queue1(2)}\")\n\n\n\n  println(\"\\nStep 3: How to add elements to Queue using +=\")\n  queue1 += \"Glazed Donut\"\n  println(s\"Elements of queue1 = $queue1\")\n\n\n\n  println(\"\\nStep 4: How to add elements to Queue using enqueue\")\n  queue1.enqueue(\"Vanilla Donut\")\n  println(s\"Enqueue element Vanilla Donut onto queue1 = $queue1\")\n\n\n\n  println(\"\\nStep 5: How to take the first element or head from the Queue\")\n  val dequeuedElement: String = queue1.dequeue\n  println(s\"Dequeued element = $dequeuedElement\")\n  println(s\"Elements of queue1 after dequeue = $queue1\")\n\n\n\n  println(\"\\nStep 6: How to initialize an empty Queue\")\n  val emptyQueue: Queue[String] = Queue.empty[String]\n  println(s\"Empty Queue = $emptyQueue\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableSet_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.seven\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Mutable Set\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-set/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject MutableSet_Tutorial extends App {\n\n\n  import scala.collection.mutable.Set\n  println(\"\\nStep 1: How to initialize a Set with 3 elements\")\n  val set1: Set[String] = Set(\"Plain Donut\",\"Strawberry Donut\",\"Chocolate Donut\")\n  println(s\"Elements of set1 = $set1\")\n\n\n\n  println(\"\\nStep 2: How to check specific elements in Set\")\n  println(s\"Element Plain Donut = ${set1(\"Plain Donut\")}\")\n  println(s\"Element Strawberry Donut = ${set1(\"Strawberry Donut\")}\")\n  println(s\"Element Chocolate Donut = ${set1(\"Chocolate Donut\")}\")\n\n\n\n  println(\"\\nStep 3: How to add elements to Set using +=\")\n  set1 += \"Vanilla Donut\"\n  println(s\"Elements of set1 after adding elements Vanilla Donut = $set1\")\n\n\n\n  println(\"\\nStep 4: How to add all elements from another Set using ++=\")\n  set1 ++= Set[String](\"Vanilla Donut\", \"Glazed Donut\")\n  println(s\"Elements of set1 after adding second set = $set1\")\n\n\n\n  println(\"\\nStep 5: How to remove element from Set using -=\")\n  set1 -= \"Plain Donut\"\n  println(s\"Elements of set1 without Plain Donut element = $set1\")\n\n\n\n  println(\"\\nStep 6: How to find the intersection between two Sets using &\")\n  val set2: Set[String] = Set(\"Vanilla Donut\", \"Glazed Donut\", \"Plain Donut\")\n  println(s\"Intersection of set1 and set5 = ${set1 & set2}\")\n\n\n\n  println(\"\\nStep 7: How to find the difference between two Sets using &~\")\n  println(s\"Difference of set1 and set2 = ${set1 &~ set2}\")\n\n\n\n  println(\"\\nStep 8: How to initialize an empty Set\")\n  val emptySet: Set[String] = Set.empty[String]\n  println(s\"Empty Set = $emptySet\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableSortedSet_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.seven\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Mutable SortedSet\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-sortedset/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject MutableSortedSet_Tutorial extends App {\n\n  import scala.collection.mutable.SortedSet\n  println(\"\\nStep 1: How to initialize a SortedSet with 3 elements\")\n  val sortedSet1: SortedSet[String] = SortedSet(\"Plain Donut\",\"Strawberry Donut\",\"Chocolate Donut\")\n  println(s\"Elements of sortedSet1 = $sortedSet1\")\n\n\n\n  println(\"\\nStep 2: How to check specific elements in SortedSet\")\n  println(s\"Element Plain Donut = ${sortedSet1(\"Plain Donut\")}\")\n  println(s\"Element Strawberry Donut = ${sortedSet1(\"Strawberry Donut\")}\")\n  println(s\"Element Chocolate Donut = ${sortedSet1(\"Chocolate Donut\")}\")\n\n\n\n  println(\"\\nStep 3: How to add elements to SortedSet using +=\")\n  sortedSet1 += \"Vanilla Donut\"\n  println(s\"Elements of sortedSet1 after adding Vanilla Donut element = $sortedSet1\")\n\n\n\n  println(\"\\nStep 4: How to add two SortedSet together using ++=\")\n  sortedSet1 ++= SortedSet[String](\"Vanilla Donut\", \"Glazed Donut\")\n  println(s\"Elements of sortedSet1 after adding second SortedSet = $sortedSet1\")\n\n\n\n  println(\"\\nStep 5: How to remove element from SortedSet using -=\")\n  sortedSet1 -= \"Plain Donut\"\n  println(s\"sortedSet1 without Plain Donut element = $sortedSet1\")\n\n\n\n  println(\"\\nStep 6: How to find the intersection between two SortedSets using &\")\n  val sortedSet2: SortedSet[String] = SortedSet(\"Vanilla Donut\", \"Glazed Donut\", \"Plain Donut\")\n  println(s\"Intersection of sortedSet1 and sortedSet5 = ${sortedSet1 & sortedSet2}\")\n\n\n\n  println(\"\\nStep 7: How to find the difference between two SortedSets using &~\")\n  println(s\"Difference of sortedSet1 and sortedSet5 = ${sortedSet1 &~ sortedSet2}\")\n\n\n\n  println(\"\\nStep 8: How to change ordering to descending alphabet in SortedSet\")\n  object DescendingAlphabetOrdering extends Ordering[String] {\n    def compare(element1:String, element2:String) = element2.compareTo(element1)\n  }\n  val sortedSet6: SortedSet[String] = SortedSet(\"Plain Donut\", \"Strawberry Donut\", \"Chocolate Donut\")(DescendingAlphabetOrdering)\n  println(s\"Elements of sortedSet6 = $sortedSet6\")\n  // NOTE: The elements are printed in descending order first with Strawberry Donut, then Plain Donut and finally Chocolate Donut\n\n\n\n  println(\"\\nStep 9: How to initialize an empty SortedSet\")\n  val emptySortedSet: SortedSet[String] = SortedSet.empty[String]\n  println(s\"Empty SortedSet = $emptySortedSet\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/MutableTreeSet_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.seven\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Mutable TreeSet\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-treeset/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject MutableTreeSet_Tutorial extends App {\n\n  import scala.collection.mutable.TreeSet\n  println(\"\\nStep 1: How to initialize a TreeSet with 3 elements\")\n  val treeSet1: TreeSet[String] = TreeSet(\"Plain Donut\",\"Strawberry Donut\",\"Chocolate Donut\")\n  println(s\"Elements of treeSet1 = $treeSet1\")\n\n\n\n  println(\"\\nStep 2: How to check specific elements in TreeSet\")\n  println(s\"Element Plain Donut = ${treeSet1(\"Plain Donut\")}\")\n  println(s\"Element Strawberry Donut = ${treeSet1(\"Strawberry Donut\")}\")\n  println(s\"Element Chocolate Donut = ${treeSet1(\"Chocolate Donut\")}\")\n\n\n\n  println(\"\\nStep 3: How to add elements to TreeSet using +=\")\n  treeSet1 += \"Vanilla Donut\"\n  println(s\"Elements of treeSet1 after adding Vanilla Donut element = $treeSet1\")\n\n\n\n  println(\"\\nStep 4: How to add two TreeSets together using ++=\")\n  treeSet1 ++= TreeSet[String](\"Vanilla Donut\", \"Glazed Donut\")\n  println(s\"Elements of treeSet1 after adding second set = $treeSet1\")\n\n\n\n  println(\"\\nStep 5: How to remove element from TreeSet using -=\")\n  treeSet1 -= \"Plain Donut\"\n  println(s\"treeSet1 without Plain Donut element = $treeSet1\")\n\n\n\n  println(\"\\nStep 6: How to find the intersection between two TreeSets using &\")\n  val treeSet2: TreeSet[String] = TreeSet(\"Vanilla Donut\", \"Glazed Donut\", \"Plain Donut\")\n  println(s\"Intersection of treeSet1 and treeSet2 = ${treeSet1 & treeSet2}\")\n\n\n\n  println(\"\\nStep 7: How to find the difference between two TreeSets using &~\")\n  println(s\"Difference of treeSet1 and treeSet2 = ${treeSet1 &~ treeSet2}\")\n\n\n\n  println(\"\\nStep 8: How to change ordering to descending alphabet in TreeSet\")\n  object DescendingAlphabetOrdering extends Ordering[String] {\n    def compare(element1:String, element2:String) = element2.compareTo(element1)\n  }\n  val treeSet3: TreeSet[String] = TreeSet(\"Plain Donut\", \"Strawberry Donut\", \"Chocolate Donut\")(DescendingAlphabetOrdering)\n  println(s\"Elements of treeSet3 = $treeSet3\")\n  // NOTE: The donut elements are  printed in descending order first with Strawberry Donut, then Plain Donut and finally Chocolate Donut\n\n\n\n  println(\"\\nStep 9: How to initialize an empty TreeSet\")\n  val emptyTreeSet: TreeSet[String] = TreeSet.empty[String]\n  println(s\"Empty TreeSet = $emptyTreeSet\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/seven/PriorityQueue_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.seven\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Mutable PriorityQueue\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-7-beginner-tutorial-using-scala-mutable-collection/scala-tutorial-learn-use-mutable-priorityqueue/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject PriorityQueue_Tutorial extends App {\n\n  println(\"Step 1: How to declare a case class to represent Donut object\")\n  case class Donut(name: String, price: Double)\n\n\n\n  println(\"\\nStep 2: How to declare a function which defines the ordering of a PriorityQueue of Donut objects\")\n  def donutOrder(d: Donut) = d.price\n  // NOTE: to order by lowest first, you can do -d.price\n\n\n\n  println(\"\\nStep 3: How to initialize a PriorityQueue of Donut objects and specify the Ordering\")\n  import scala.collection.mutable.PriorityQueue\n  val priorityQueue1: PriorityQueue[Donut] = PriorityQueue(\n    Donut(\"Plain Donut\", 1.50),\n    Donut(\"Strawberry Donut\", 2.0),\n    Donut(\"Chocolate Donut\", 2.50))(Ordering.by(donutOrder))\n  println(s\"Elements of priorityQueue1 = $priorityQueue1\")\n\n\n\n  println(\"\\nStep 4: How to add an element to PriorityQueue using enqueue function\")\n  priorityQueue1.enqueue(Donut(\"Vanilla Donut\", 1.0))\n  println(s\"Elements of priorityQueue1 after enqueue function is called = $priorityQueue1\")\n\n\n\n  println(\"\\nStep 5: How to add an element to PriorityQueue using +=\")\n  priorityQueue1 += (Donut(\"Krispy Kreme Donut\", 1.0))\n  println(s\"Elements of priorityQueue1 after enqueue function is called = $priorityQueue1\")\n\n\n\n  println(\"\\nStep 6: How to remove an element from PriorityQueue using the dequeue function\")\n  val donutDequeued: Donut = priorityQueue1.dequeue()\n  println(s\"Donut element dequeued = $donutDequeued\")\n  // NOTE: the highest element in the queue order by price was removed\n  println(s\"Elements of priorityQueue1 after dequeued function is called = $priorityQueue1\")\n\n\n\n  println(\"\\nStep 7: How to initialize an empty PriorityQueue\")\n  val emptyPriorityQueue: PriorityQueue[String] = PriorityQueue.empty[String]\n  println(s\"Empty emptyPriorityQueue = $emptyPriorityQueue\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableBitSet_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.six\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Immutable BitSet\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-bitset/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ImmutableBitSet_Tutorial extends App {\n\n\n  import scala.collection.immutable.BitSet\n  println(\"Step 1: How to initialize a BitSet with 3 elements\")\n  val bitSet1: BitSet = BitSet(3, 2, 0)\n  println(s\"Elements of bitSet1 = $bitSet1\")\n\n\n\n  println(\"\\nStep 2: How to check specific elements in BitSet\")\n  println(s\"Element 0 = ${bitSet1(0)}\")\n  println(s\"Element 2 = ${bitSet1(2)}\")\n  println(s\"Element 3 = ${bitSet1(3)}\")\n\n\n\n  println(\"\\nStep 3: How to add elements in BitSet using +\")\n  val bitSet2: BitSet = bitSet1 + 13 + 13\n  println(s\"Adding elements to BitSet using + = $bitSet2\")\n  // NOTE: we only have one 13 element and not two as BitSet is distinct\n\n\n\n  println(\"\\nStep 4: How to add two BitSets together using ++\")\n  val bitSet3: BitSet = bitSet1 ++ BitSet(13, 14, 15, 16, 17)\n  println(s\"Add two BitSets together using ++ = $bitSet3\")\n\n\n\n  println(\"\\nStep 5: How to remove element in BitSet using -\")\n  val bitSet4: BitSet = bitSet1 - 0\n  println(s\"BitSet without element 0 = $bitSet4\")\n\n\n\n  println(\"\\nStep 6: How to find the intersection between two BitSets using &\")\n  val bitSet5: BitSet = BitSet(0, 2, 4)\n  println(s\"Intersection of bitSet1 and bitSet5 = ${bitSet1 & bitSet5}\")\n\n\n\n  println(\"\\nStep 7: How to find the difference between two BitSets using &~\")\n  println(s\"Difference of bitSet1 and bitSet5 = ${bitSet1 &~ bitSet5}\")\n\n\n\n  println(\"\\nStep 8: How to initialize an empty BitSet\")\n  val emptyBitSet: BitSet = BitSet.empty\n  println(s\"Empty BitSet = $emptyBitSet\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableHashMap_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.six\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Immutable HashMap\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-hashmap/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ImmutableHashMap_Tutorial extends App {\n\n  import scala.collection.immutable.HashMap\n  println(\"Step 1: How to initialize a HashMap with 3 elements using Tuples of key and value\")\n  val hashMap1: HashMap[String, String] = HashMap((\"PD\",\"Plain Donut\"),(\"SD\",\"Strawberry Donut\"),(\"CD\",\"Chocolate Donut\"))\n  println(s\"Elements of hashMap1 = $hashMap1\")\n\n\n\n  println(\"\\nStep 2: How to initialize HashMap using key -> value notation\")\n  val hashMap2: HashMap[String, String] = HashMap(\"VD\"-> \"Vanilla Donut\", \"GD\" -> \"Glazed Donut\")\n  println(s\"Elements of hashMap2 = $hashMap2\")\n\n\n\n  println(\"\\nStep 3: How to access elements in HashMap by specific key\")\n  println(s\"Element by key VD = ${hashMap2(\"VD\")}\")\n  println(s\"Element by key GD = ${hashMap2(\"GD\")}\")\n\n\n\n  println(\"\\nStep 4: How to add elements to HashMap using +\")\n  val hashMap3: HashMap[String, String] = hashMap1 + (\"KD\" -> \"Krispy Kreme Donut\")\n  println(s\"Element in hashMap3 = $hashMap3\")\n\n\n\n  println(\"\\nStep 5: How to add two HashMaps together using ++\")\n  val hashMap4: Map[String, String] = hashMap1 ++ hashMap2\n  println(s\"Elements in hashMap4 = $hashMap4\")\n\n\n\n  println(\"\\nStep 6: How to remove key and its value from HashMap using -\")\n  val hashMap5: Map[String, String] = hashMap4 - (\"CD\")\n  println(s\"HashMap without the key CD and its value = $hashMap5\")\n\n\n\n  println(\"\\nStep 7: How to initialize an empty HashMap\")\n  val emptyHashMap: HashMap[String,String] = HashMap.empty[String,String]\n  println(s\"Empty HashMap = $emptyHashMap\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableHashSet_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.six\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Immutable HashSet\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-hashset/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ImmutableHashSet_Tutorial extends App {\n\n  import scala.collection.immutable.HashSet\n  println(\"Step 1: How to initialize a HashSet with 3 elements\")\n  val hashSet1: HashSet[String] = HashSet(\"Plain Donut\",\"Strawberry Donut\",\"Chocolate Donut\")\n  println(s\"Elements of hashSet1 = $hashSet1\")\n\n\n\n  println(\"\\nStep 2: How to check specific elements in HashSet\")\n  println(s\"Element Plain Donut = ${hashSet1(\"Plain Donut\")}\")\n  println(s\"Element Strawberry Donut = ${hashSet1(\"Strawberry Donut\")}\")\n  println(s\"Element Chocolate Donut = ${hashSet1(\"Chocolate Donut\")}\")\n\n\n\n  println(\"\\nStep 3: How to add elements in HashSet using +\")\n  val hashSet2: HashSet[String] = hashSet1 + \"Vanilla Donut\" + \"Vanilla Donut\"\n  println(s\"Adding elements to HashSet using + = $hashSet2\")\n  // NOTE: we only have one Vanilla Donut element and not two as sets are distinct\n\n\n\n  println(\"\\nStep 4: How to add two HashSets together using ++\")\n  val hashSet3: HashSet[String] = hashSet1 ++ HashSet[String](\"Vanilla Donut\", \"Glazed Donut\")\n  println(s\"Add two HashSets together using ++ = $hashSet3\")\n\n\n\n  println(\"\\nStep 5: How to remove element in HashSet using -\")\n  val hashSet4: HashSet[String] = hashSet1 - \"Plain Donut\"\n  println(s\"HashSet without Plain Donut element = $hashSet4\")\n\n\n\n  println(\"\\nStep 6: How to find the intersection between two HashSets using &\")\n  val hashSet5: HashSet[String] = HashSet(\"Vanilla Donut\", \"Glazed Donut\", \"Plain Donut\")\n  println(s\"Intersection of hashSet1 and hashSet5 = ${hashSet1 & hashSet5}\")\n\n\n\n  println(\"\\nStep 7: How to find the difference between two HashSets using &~\")\n  println(s\"Difference of hashSet1 and hashSet5 = ${hashSet1 &~ hashSet5}\")\n\n\n\n  println(\"\\nStep 8: How to initialize an empty HashSet\")\n  val emptyHashSet: HashSet[String] = HashSet.empty[String]\n  println(s\"Empty HashSet = $emptyHashSet\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableListMap_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.six\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Immutable ListMap\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-listmap/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ImmutableListMap_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a ListMap with 3 elements using key -> value notation\")\n  import scala.collection.immutable.ListMap\n  val listMap1: ListMap[String, String] = ListMap(\"PD\" -> \"Plain Donut\", \"SD\" ->\"Strawberry Donut\", \"CD\" -> \"Chocolate Donut\")\n  println(s\"Elements of listMap1 = $listMap1\")\n\n\n\n  println(\"\\nStep 2: How to access elements by specific key in the ListMap\")\n  println(s\"Element by key PD = ${listMap1(\"PD\")}\")\n  println(s\"Element by key SD = ${listMap1(\"SD\")}\")\n\n\n\n  println(\"\\nStep 3: How to add elements to ListMap using +\")\n  val listMap2: ListMap[String, String] = listMap1 + (\"KD\" -> \"Krispy Kreme Donut\")\n  println(s\"Elements of listMap2 = $listMap2\")\n\n\n\n  println(\"\\nStep 4: How to add two ListMaps together using ++\")\n  val listMap3: ListMap[String, String] = listMap1 ++ listMap2\n  println(s\"Elements of listMap3 = $listMap3\")\n\n\n\n  println(\"\\nStep 5: How to remove key and value from ListMap using -\")\n  val listMap4: ListMap[String, String] = listMap1 - (\"CD\")\n  println(s\"ListMap without the key CD and its value = $listMap4\")\n\n\n\n  println(\"\\nStep 6: How to initialize an empty ListMap\")\n  val emptyListMap: ListMap[String, String] = ListMap.empty[String,String]\n  println(s\"Empty ListMap with key type String and value also of type String= $emptyListMap\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableListSet_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.six\n\nimport scala.collection.immutable.ListSet\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Immutable ListSet\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-listset/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ImmutableListSet_Tutorial extends App {\n\n  println(\"Step 1: How to initialize an immutable ListSet with 3 elements\")\n  val listSet1: ListSet[String] = ListSet(\"Plain Donut\",\"Strawberry Donut\",\"Chocolate Donut\")\n  println(s\"Elements of listSet1 = $listSet1\")\n\n\n\n  println(\"\\nStep 2: How to check elements of immutable ListSet\")\n  println(s\"Element Plain Donut = ${listSet1(\"Plain Donut\")}\")\n  println(s\"Element Strawberry Donut = ${listSet1(\"Strawberry Donut\")}\")\n  println(s\"Element Chocolate Donut = ${listSet1(\"Chocolate Donut\")}\")\n\n\n\n  println(\"\\nStep 3: How to add elements of immutable ListSet using +\")\n  val listSet2: ListSet[String] = listSet1 + \"Vanilla Donut\"\n  println(s\"Adding element Vanilla to ListSet using + = $listSet2\")\n\n\n\n  println(\"\\nStep 4: How to add two ListSet together using ++\")\n  val listSet3: ListSet[String] = listSet1 ++ ListSet(\"Glazed Donut\")\n  println(s\"Add two lists together using ++ = $listSet3\")\n\n\n\n  println(\"\\nStep 5: How to remove element from the ListSet using -\")\n  val listSet4: ListSet[String] = listSet1 - (\"Plain Donut\")\n  println(s\"ListSet without the element Plain Donut = $listSet4\")\n\n\n\n  println(\"\\nStep 6: How to initialize an empty ListSet\")\n  val emptyListSet: ListSet[String] = ListSet.empty[String]\n  println(s\"Empty ListSet of type String = $emptyListSet\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableList_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.six\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Immutable List\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-list/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ImmutableList_Tutorial extends App {\n\n\n  println(\"Step 1: How to initialize an immutable List with 3 elements\")\n  val list1: List[String] = List(\"Plain Donut\",\"Strawberry Donut\",\"Chocolate Donut\")\n  println(s\"Elements of list1 = $list1\")\n\n\n\n  println(\"\\nStep 2: How to access elements of immutable List at specific index\")\n  println(s\"Element at index 0 = ${list1(0)}\")\n  println(s\"Element at index 1 = ${list1(1)}\")\n  println(s\"Element at index 2 = ${list1(2)}\")\n\n\n\n  println(\"\\nStep 3: How to append elements at the end of immutable List using :+\")\n  val list2: List[String] = list1 :+ \"Vanilla Donut\"\n  println(s\"Append elements at the end using :+ = $list2\")\n\n\n\n  println(\"\\nStep 4: How to prepend elements at the front of immutable List using +:\")\n  val list3: List[String] = \"Vanilla Donut\" +: list1\n  println(s\"Prepend elements at the front using +: = $list3\")\n\n\n\n  println(\"\\nStep 5: How to add two immutable lists together using ::\")\n  val list4: List[Any] = list1 :: list2\n  println(s\"Add two lists together using :: = $list4\")\n\n\n\n  println(\"\\nStep 6: How to add two immutable Lists together using :::\")\n  val list5: List[String] = list1 ::: list2\n  println(s\"Add two lists together using ::: = $list5\")\n\n\n\n  println(\"\\nStep 7: How to initialize an empty immutable List\")\n  val emptyList: List[String] = List.empty[String]\n  println(s\"Empty list = $emptyList\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableMap_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.six\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Immutable Map\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-map/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ImmutableMap_Tutorial extends App {\n\n\n  println(\"Step 1: How to initialize a Map with 3 elements\")\n  val map1: Map[String, String] = Map((\"PD\",\"Plain Donut\"),(\"SD\",\"Strawberry Donut\"),(\"CD\",\"Chocolate Donut\"))\n  println(s\"Elements of map1 = $map1\")\n\n\n\n  println(\"\\nStep 2: How to initialize Map using key -> value notation\")\n  val map2: Map[String, String] = Map(\"VD\"-> \"Vanilla Donut\", \"GD\" -> \"Glazed Donut\")\n  println(s\"Elements of map1 = $map2\")\n\n\n\n  println(\"\\nStep 3: How to access elements by specific key\")\n  println(s\"Element by key VD = ${map2(\"VD\")}\")\n  println(s\"Element by key GD = ${map2(\"GD\")}\")\n\n\n\n  println(\"\\nStep 4: How to add elements using +\")\n  val map3: Map[String, String] = map1 + (\"KD\" -> \"Krispy Kreme Donut\")\n  println(s\"Element in map3 = $map3\")\n\n\n\n  println(\"\\nStep 5: How to add two Maps together using ++\")\n  val map4: Map[String, String] = map1 ++ map2\n  println(s\"Elements in map4 = $map4\")\n\n\n\n  println(\"\\nStep 6: How to remove key and its value from map using -\")\n  val map5: Map[String, String] = map4 - (\"CD\")\n  println(s\"Map without the key CD and its value = $map5\")\n\n\n\n  println(\"\\nStep 7: How to initialize an empty Map\")\n  val emptyMap: Map[String,String] = Map.empty[String,String]\n  println(s\"Empty Map = $emptyMap\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableQueue_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.six\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Immutable Queue\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-queue/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ImmutableQueue_Tutorial extends App {\n\n  import scala.collection.immutable.Queue\n  println(\"Step 1: How to initialize a Queue with 3 elements\")\n  val queue1: Queue[String] = Queue(\"Plain Donut\", \"Strawberry Donut\", \"Chocolate Donut\")\n  println(s\"Elements of queue1 = $queue1\")\n  // NOTE: FIFO\n\n\n\n  println(\"\\nStep 2: How to access elements at specific index in a Queue\")\n  println(s\"Element at index 0 = ${queue1(0)}\")\n  println(s\"Element at index 0 = ${queue1(1)}\")\n  println(s\"Element at index 0 = ${queue1(2)}\")\n\n\n\n  println(\"\\nStep 3: How to add elements in a Queue using :+\")\n  val queue2: Queue[String] = queue1 :+ \"Glazed Donut\"\n  println(s\"Elements of queue2 = $queue2\")\n\n\n\n  println(\"\\nStep 4: How to add elements in Queue using enqueue function\")\n  val enqueue: Queue[String] = queue1.enqueue(\"Vanilla Donut\")\n  println(s\"Enqueue element Vanilla Donut onto queue1 = $enqueue\")\n\n\n\n  println(\"\\nStep 5: How to take the first element from the Queue using dequeue function\")\n  val dequeue: (String, Queue[String]) = queue1.dequeue\n  println(s\"First element dequeue = ${dequeue._1}\")\n  println(s\"Remaining elements after dequeue = ${dequeue._2}\")\n  // NOTE: dequeue returns a pair (element, the remaining elements of the queue)\n\n\n\n  println(\"\\nStep 6: How to add two Queues together using ++\")\n  val queue3: Queue[String] = queue1 ++ Queue[String](\"Glazed Donut\", \"Vanilla Donut\")\n  println(s\"Elements in queue3 = $queue3\")\n\n\n\n  println(\"\\nStep 7: How to initialize an empty Queue\")\n  val emptyQueue: Queue[String] = Queue.empty[String]\n  println(s\"Empty Queue = $emptyQueue\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableSequence_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.six\n\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Immutable Sequence\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-sequence/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ImmutableSequence_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Sequence with 3 elements\")\n  val seq1: Seq[String] = Seq(\"Plain Donut\",\"Strawberry Donut\",\"Chocolate Donut\")\n  println(s\"Elements of seq1 = $seq1\")\n\n\n\n  println(\"\\nStep 2: How to access elements in Sequence at specific index\")\n  println(s\"Element at index 0 = ${seq1(0)}\")\n  println(s\"Element at index 1 = ${seq1(1)}\")\n  println(s\"Element at index 2 = ${seq1(2)}\")\n\n\n\n  println(\"\\nStep 3: How to add elements to Sequence using :+\")\n  val seq2: Seq[String] = seq1 :+ \"Vanilla Donut\"\n  println(s\"Adding elements to Sequence using :+ = $seq2\")\n\n\n\n  println(\"\\nStep 4: How to add two Sequence together using ++\")\n  val seq3: Seq[String] = seq1 ++ Seq[String](\"Vanilla Donut\", \"Glazed Donut\")\n  println(s\"Add two sequences together using ++ = $seq3\")\n\n\n\n  println(\"\\nStep 5: How to initialize an empty Sequence\")\n  val emptySeq: Seq[String] = Seq.empty[String]\n  println(s\"Empty Sequence = $emptySeq\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableSet_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.six\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Immutable Set\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-set/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ImmutableSet_Tutorial extends App {\n\n  println(\"Step 1: How to initialize a Set with 3 elements\")\n  val set1: Set[String] = Set(\"Plain Donut\",\"Strawberry Donut\",\"Chocolate Donut\")\n  println(s\"Elements of set1 = $set1\")\n\n\n\n  println(\"\\nStep 2: How to check specific elements exists in Set\")\n  println(s\"Element Plain Donut = ${set1(\"Plain Donut\")}\")\n  println(s\"Element Strawberry Donut = ${set1(\"Strawberry Donut\")}\")\n  println(s\"Element Chocolate Donut = ${set1(\"Chocolate Donut\")}\")\n\n\n\n  println(\"\\nStep 3: How to add elements in Set using +\")\n  val set2: Set[String] = set1 + \"Vanilla Donut\" + \"Vanilla Donut\"\n  println(s\"Adding elements to Set using + = $set2\")\n\n\n\n  println(\"\\nStep 4: How to add two Sets together using ++\")\n  val set3: Set[String] = set1 ++ Set[String](\"Vanilla Donut\", \"Glazed Donut\")\n  println(s\"Add two Sets together using ++ = $set3\")\n\n\n\n  println(\"\\nStep 5: How to remove element from Set using -\")\n  val set4: Set[String] = set1 - \"Plain Donut\"\n  println(s\"Set without Plain Donut element = $set4\")\n\n\n\n  println(\"\\nStep 6: How to find the intersection between two Sets using &\")\n  val set5: Set[String] = Set(\"Vanilla Donut\", \"Glazed Donut\", \"Plain Donut\")\n  println(s\"Intersection of set1 and set5 = ${set1 & set5}\")\n\n\n\n  println(\"\\nStep 7: How to find the difference between two Sets using &~\")\n  println(s\"Difference between set1 and set5 = ${set1 &~ set5}\")\n\n\n\n  println(\"\\nStep 8: How to initialize an empty Set\")\n  val emptySet: Set[String] = Set.empty[String]\n  println(s\"Empty Set = $emptySet\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableSortedSet_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.six\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Immutable SortedSet\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-sortedset/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ImmutableSortedSet_Tutorial extends App {\n\n  import scala.collection.immutable.SortedSet\n  println(\"Step 1: How to initialize a SortedSet with 3 elements\")\n  val sortedSet1: SortedSet[String] = SortedSet(\"Plain Donut\",\"Strawberry Donut\",\"Chocolate Donut\")\n  println(s\"Elements of sortedSet1 = $sortedSet1\")\n\n\n\n  println(\"\\nStep 2: How to check specific elements in SortedSet\")\n  println(s\"Element Plain Donut = ${sortedSet1(\"Plain Donut\")}\")\n  println(s\"Element Strawberry Donut = ${sortedSet1(\"Strawberry Donut\")}\")\n  println(s\"Element Chocolate Donut = ${sortedSet1(\"Chocolate Donut\")}\")\n\n\n\n  println(\"\\nStep 3: How to add elements to SortedSet using +\")\n  val sortedSet2: SortedSet[String] = sortedSet1 + \"Vanilla Donut\" + \"Vanilla Donut\"\n  println(s\"Adding elements to SortedSet using + = $sortedSet2\")\n  // NOTE: we only have one Vanilla Donut element and not two as SortedSet is distinct\n\n\n\n  println(\"\\nStep 4: How to add two SortedSets together using ++\")\n  val sortedSet3: SortedSet[String] = sortedSet1 ++ SortedSet[String](\"Vanilla Donut\", \"Glazed Donut\")\n  println(s\"Add two SortedSets together using ++ = $sortedSet3\")\n\n\n  println(\"\\nStep 5: How to remove element in SortedSet using -\")\n  val sortedSet4: SortedSet[String] = sortedSet1 - \"Plain Donut\"\n  println(s\"SortedSet without Plain Donut element = $sortedSet4\")\n\n\n\n  println(\"\\nStep 6: How to find the intersection between two SortedSets using &\")\n  val sortedSet5: SortedSet[String] = SortedSet(\"Vanilla Donut\", \"Glazed Donut\", \"Plain Donut\")\n  println(s\"Intersection of sortedSet1 and sortedSet5 = ${sortedSet1 & sortedSet5}\")\n\n\n\n  println(\"\\nStep 7: How to find the difference between two SortedSets using &~\")\n  println(s\"Difference of sortedSet1 and sortedSet5 = ${sortedSet1 &~ sortedSet5}\")\n\n\n\n  println(\"\\nStep 8: How to change ordering of SortedSet to descending alphabet\")\n  object AlphabetOrdering extends Ordering[String] {\n    def compare(element1:String, element2:String) = element2.compareTo(element1)\n  }\n  val sortedSet6: SortedSet[String] = SortedSet(\"Plain Donut\", \"Strawberry Donut\", \"Chocolate Donut\")(AlphabetOrdering)\n  println(s\"Elements of sortedSet6 = $sortedSet6\")\n  // NOTE: The elements are now printed in descending order first with Strawberry Donut, then Plain Donut and finally Chocolate Donut\n\n\n\n  println(\"\\nStep 9: How to initialize an empty SortedSet\")\n  val emptySortedSet: SortedSet[String] = SortedSet.empty[String]\n  println(s\"Empty SortedSet = $emptySortedSet\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableStack_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.six\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Immutable Stack\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-stack/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ImmutableStack_Tutorial extends App {\n\n  import scala.collection.immutable.Stack\n  println(\"Step 1: How to initialize Stack with 3 elements\")\n  val stack1: Stack[String] = Stack(\"Plain Donut\", \"Strawberry Donut\", \"Chocolate Donut\")\n  println(s\"Elements of stack1 = $stack1\")\n\n\n\n  println(\"\\nStep 2: How to initialize a Stack using an Immutable List\")\n  val stack2: List[String] = List(\"Plain Donut\",\"Strawberry Donut\",\"Chocolate Donut\")\n  println(s\"Using an Immutable List for stack, elements are = $stack2\")\n\n\n\n  println(\"\\nStep 3: Push one element at the top of the stack using :: of Immutable List\")\n  val stack3: List[String] = \"Vanilla Donut\" :: stack2\n  println(s\"Using an Immutable List for stack, elements after push = $stack3\")\n\n\n\n  println(\"\\nStep 4: Push N elements at the top of the stack using :: of Immutable List\")\n  val stack4: List[String] = \"Glazed Donut\" :: \"Vanilla Donut\" :: stack2\n  println(s\"Using an Immutable List for stack, elements after pushing N elements  = $stack4\")\n\n\n\n  println(\"\\nStep 5: Pop element from the Stack using tail function of Immutable List\")\n  val stack5: List[String] = stack2.tail\n  println(s\"Using an Immutable List for stack, elements after tail function to simulate Stack pop = $stack5\")\n\n\n\n  println(\"\\nStep 6: How to initialize an empty Stack using Immutable List\")\n  val emptyStack: List[String] = List.empty[String]\n  println(s\"Using an Immutable List for stack, the empty stack = $emptyStack\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableStream_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.six\n\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Immutable Stream\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-stream/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ImmutableStream_Tutorial extends App {\n\n\n  println(\"Step 1: How to create a Stream with 3 numbers using #::\")\n  val stream1: Stream[Int] = 1 #:: 2 #:: 3 #:: Stream.empty\n  println(s\"Elements of stream1 = $stream1\")\n\n\n\n  import scala.collection.immutable.Stream.cons\n  println(\"\\nStep 2: How to create a Stream with 3 numbers using Stream.cons\")\n  val stream2: Stream[Int]  = cons(1, cons(2, cons(3, Stream.empty) ) )\n  println(s\"Elements of stream2 = ${stream2}\")\n\n\n\n  println(\"\\nStep 3: How to print all 3 numbers from stream2 using the take function\")\n  print(\"Take first 3 numbers from stream2 = \")\n  stream2.take(3).print\n\n  print(\"\\nTake first 10 numbers from stream2 = \")\n  stream2.take(10).print\n\n\n\n  println(\"\\n\\nStep 4: How to define an infinite Stream of numbers using Stream.cons\")\n  def inifiniteNumberStream(number: Int): Stream[Int] = Stream.cons(number, inifiniteNumberStream(number + 1))\n  print(\"Take only the first 20 numbers from the infinite number stream = \")\n  inifiniteNumberStream(1).take(20).print\n\n\n\n  println(\"\\n\\nStep 5: How to define an infinite stream of numbers using Stream.from\")\n  val stream3: Stream[Int]  = Stream.from(1)\n  print(\"Take only the first 20 numbers from the infinite number stream = \")\n  stream3.take(20).print\n\n\n\n  println(\"\\n\\nStep 6: How to initialize an empty Stream\")\n  val emptyStream: Stream[Int] = Stream.empty[Int]\n  println(s\"Empty Stream = $emptyStream\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableTreeMap_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.six\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Immutable TreehMap\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-treemap/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ImmutableTreeMap_Tutorial extends App {\n\n  import scala.collection.immutable.TreeMap\n  println(\"Step 1: How to initialize a TreeMap with 3 elements using Tuples key and value\")\n  val treeMap1: TreeMap[String, String] = TreeMap((\"PD\",\"Plain Donut\"),(\"SD\",\"Strawberry Donut\"),(\"CD\",\"Chocolate Donut\"))\n  println(s\"Elements of treeMap1 = $treeMap1\")\n  // NOTE: it is sorted by the key so CD is first followed by PD and then SD\n\n\n\n  println(\"\\nStep 2: How to initialize TreeMap using key -> value notation\")\n  val treeMap2: TreeMap[String, String] = TreeMap(\"VD\"-> \"Vanilla Donut\", \"GD\" -> \"Glazed Donut\")\n  println(s\"Elements of treeMap2 = $treeMap2\")\n\n\n\n  println(\"\\nStep 3: How to access elements of TreeMap by specific key\")\n  println(s\"Element by key VD = ${treeMap2(\"VD\")}\")\n  println(s\"Element by key GD = ${treeMap2(\"GD\")}\")\n\n\n\n  println(\"\\nStep 4: How to add elements to TreeMap using +\")\n  val treeMap3: TreeMap[String, String] = treeMap1 + (\"KD\" -> \"Krispy Kreme Donut\")\n  println(s\"Elements in treeMap3 = $treeMap3\")\n\n\n\n  println(\"\\nStep 5: How to add two TreeMaps together using ++\")\n  val treeMap4: TreeMap[String, String] = treeMap1 ++ treeMap2\n  println(s\"Elements in treeMap4 = $treeMap4\")\n\n\n\n  println(\"\\nStep 6: How to remove key and its value from TreeMap using -\")\n  val treeMap5: TreeMap[String, String] = treeMap4 - (\"CD\")\n  println(s\"TreeMap without the key CD and its value = $treeMap5\")\n\n\n\n  println(\"\\nStep 7: How to change ordering of TreeMap to descending alphabet\")\n  object AlphabetOrdering extends Ordering[String] {\n    def compare(key1:String, key2:String) = key2.compareTo(key1)\n  }\n  val treeMap6: TreeMap[String, String] = TreeMap((\"PD\",\"Plain Donut\"),(\"SD\",\"Strawberry Donut\"),(\"CD\",\"Chocolate Donut\"))(AlphabetOrdering)\n  println(s\"Elements of treeMap6 in descending order = $treeMap6\")\n  // NOTE: SD is printed first followed by PD and then CD\n\n\n\n  println(\"\\nStep 8: How to initialize an empty TreeMap\")\n  val emptyTreeMap: TreeMap[String,String] = TreeMap.empty[String,String]\n  println(s\"Empty TreeMap = $emptyTreeMap\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableTreeSet_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.six\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Immutable TreeSet\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-treeset/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ImmutableTreeSet_Tutorial extends App {\n\n\n  import scala.collection.immutable.TreeSet\n  println(\"Step 1: How to initialize a TreeSet with 3 elements\")\n  val treeSet1: TreeSet[String] = TreeSet(\"Plain Donut\",\"Strawberry Donut\",\"Chocolate Donut\")\n  println(s\"Elements of treeSet1 = $treeSet1\")\n\n\n\n  println(\"\\nStep 2: How to check specific elements in TreeSet\")\n  println(s\"Element Plain Donut = ${treeSet1(\"Plain Donut\")}\")\n  println(s\"Element Strawberry Donut = ${treeSet1(\"Strawberry Donut\")}\")\n  println(s\"Element Chocolate Donut = ${treeSet1(\"Chocolate Donut\")}\")\n\n\n\n  println(\"\\nStep 3: How to add elements to TreeSet using +\")\n  val treeSet2: TreeSet[String] = treeSet1 + \"Vanilla Donut\" + \"Vanilla Donut\"\n  println(s\"Adding elements to TreeSet using + = $treeSet2\")\n  // NOTE: we only have one Vanilla Donut element and not two as sets are distinct\n\n\n\n  println(\"\\nStep 4: How to add two TreeSets together using ++\")\n  val treeSet3: TreeSet[String] = treeSet1 ++ TreeSet[String](\"Vanilla Donut\", \"Glazed Donut\")\n  println(s\"Add two TreeSets together using ++ = $treeSet3\")\n\n\n\n  println(\"\\nStep 5: How to remove element in TreeSet using -\")\n  val treeSet4: TreeSet[String] = treeSet1 - \"Plain Donut\"\n  println(s\"TreeSet without Plain Donut element = $treeSet4\")\n\n\n\n  println(\"\\nStep 6: How to find the intersection between two TreeSets using &\")\n  val treeSet5: TreeSet[String] = TreeSet(\"Vanilla Donut\", \"Glazed Donut\", \"Plain Donut\")\n  println(s\"Intersection of treeSet1 and treeSet5 = ${treeSet1 & treeSet5}\")\n\n\n\n  println(\"\\nStep 7: How to find the difference between two TreeSets using &~\")\n  println(s\"Difference of treeSet1 and treeSet5 = ${treeSet1 &~ treeSet5}\")\n\n\n\n  println(\"\\nStep 8: How to change ordering of TreeSet to descending alphabet\")\n  object AlphabetOrdering extends Ordering[String] {\n    def compare(element1:String, element2:String) = element2.compareTo(element1)\n  }\n  val treeSet6: TreeSet[String] = TreeSet(\"Plain Donut\", \"Strawberry Donut\", \"Chocolate Donut\")(AlphabetOrdering)\n  println(s\"Elements of treeSet6 = $treeSet6\")\n  // NOTE: our elements are now printed in descending order first with Strawberry Donut, then Plain Donut and finally Chocolate Donut\n\n\n\n  println(\"\\nStep 9: How to initialize an empty TreeSet\")\n  val emptyTreeSet: TreeSet[String] = TreeSet.empty[String]\n  println(s\"Empty TreeSet = $emptyTreeSet\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/six/ImmutableVector_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.six\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Scala's Immutable Vector\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-6-beginner-tutorial-using-scala-immutable-collection/scala-tutorial-learn-use-immutable-vector/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ImmutableVector_Tutorial extends App {\n\n\n  println(\"Step 1: How to initialize a Vector with 3 elements\")\n  val vector1: Vector[String] = Vector(\"Plain Donut\", \"Strawberry Donut\", \"Chocolate Donut\")\n  println(s\"Elements of vector1 = $vector1\")\n\n\n\n  println(\"\\nStep 2: How to access elements of Vector at specific index\")\n  println(s\"Element at index 0 = ${vector1(0)}\")\n  println(s\"Element at index 1 = ${vector1(1)}\")\n  println(s\"Element at index 2 = ${vector1(2)}\")\n\n\n\n  println(\"\\nStep 3: How to append elements at the end of Vector using :+\")\n  val vector2 = vector1 :+ \"Vanilla Donut\"\n  println(s\"Adding elements to Vector using :+ = $vector2\")\n\n\n\n  println(\"\\nStep 4: How to prepend elements in front of Vector using +:\")\n  val vector3 = \"Vanilla Donut\" +: vector1\n  println(s\"Adding elements to Vector using :+ = $vector3\")\n\n\n\n  println(\"\\nStep 5: How to add two Vectors together using ++\")\n  val vector4 = vector1 ++ Vector[String](\"Glazed Donut\")\n  println(s\"Add two vectors together using ++ = $vector3\")\n  // NOTE: this return a new Vector(...), elements from the second vector)\n\n\n\n  println(\"\\nStep 6: How to initialize an empty Vector\")\n  val emptyVector: Vector[String] = Vector.empty[String]\n  println(s\"Empty vector of type String = $emptyVector\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/CreateAndUseFunction_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\n/**\n  * Created by Nadim Bahadoor on 26/06/2016.\n  *\n  *  Tutorial: Learn How To Create And Use Functions\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-use-functions/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject CreateAndUseFunction_Tutorial extends App {\n\n\n  println(\"Step 1: How to define and use a function which has a return type\")\n  def favoriteDonut(): String = {\n    \"Glazed Donut\"\n  }\n\n  val myFavoriteDonut = favoriteDonut()\n  println(s\"My favorite donut is $myFavoriteDonut\")\n\n\n\n  println(\"\\nStep 2: How to define and use a function with no parenthesis\")\n  def leastFavoriteDonut = \"Plain Donut\"\n  println(s\"My least favorite donut is $leastFavoriteDonut\")\n\n\n\n  println(\"\\nStep 3: How to define and use a function with no return type\")\n  def printDonutSalesReport(): Unit = {\n    // lookup sales data in database and create some report\n    println(\"Printing donut sales report... done!\")\n  }\n  printDonutSalesReport()\n\n\n\n  println(\"\\nStep 4: Use type inference to define function with no return type\")\n  def printReport {\n    // lookup sales data in database and create some report\n    println(\"Printing donut report... done!\")\n  }\n  printReport\n\n\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionAsValues_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\nimport scala.util.Random\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Function Using The Val Keyword Instead Of Def\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-val-function-val-vs-def/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionAsValues_Tutorial extends App {\n\n  println(\"\\nStep 1: How to define a higher order function which takes another function as parameter\")\n  def totalCostWithDiscountFunctionParameter(donutType: String)(quantity: Int)(f: Double => Double): Double = {\n    println(s\"Calculating total cost for $quantity $donutType\")\n    val totalCost = 2.50 * quantity\n    f(totalCost)\n  }\n\n\n\n  println(\"\\nStep 2: How to define and pass a def function to a higher order function\")\n  def applyDiscount(totalCost: Double): Double = {\n    val discount = 2 // assume you fetch discount from database\n    totalCost - discount\n  }\n  println(s\"Total cost of 5 Glazed Donuts with discount def function = ${totalCostWithDiscountFunctionParameter(\"Glazed Donut\")(5)(applyDiscount(_))}\")\n\n\n\n  println(\"\\nStep 3: How to define and pass a val function to a higher order function\")\n  val applyDiscountValueFunction = (totalCost: Double) => {\n//  val applyDiscountValueFunction: Double => Double = totalCost => { // val function syntax with return type\n    val discount = 2 // assume you fetch discount from database\n    totalCost - discount\n  }\n  println(s\"Total cost of 5 Glazed Donuts with discount val function = ${totalCostWithDiscountFunctionParameter(\"Glazed Donut\")(5)(applyDiscountValueFunction)}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionByName_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\nimport scala.util.Random\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Call By Name Function\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-call-name-function/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionByName_Tutorial extends App {\n\n\n  println(\"Step 1: How to define a List with Tuple3 elements\")\n  val listOrders = List((\"Glazed Donut\", 5, 2.50), (\"Vanilla Donut\", 10, 3.50))\n\n\n\n  println(\"\\nStep 2: How to define a function to loop through each Tuple3 of the List and calculate total cost\")\n  def placeOrder(orders: List[(String, Int, Double)])(exchangeRate: Double): Double = {\n    var totalCost: Double = 0.0\n    orders.foreach {order =>\n      val costOfItem = order._2 * order._3 * exchangeRate\n      println(s\"Cost of ${order._2} ${order._1} = £$costOfItem\")\n      totalCost += costOfItem\n    }\n    totalCost\n  }\n\n\n\n  println(\"\\nStep 3: How to call function with curried group parameter for List of Tuple3 elements\")\n  println(s\"Total cost of order = £${placeOrder(listOrders)(0.5)}\")\n\n\n\n  println(\"\\nStep 4: How to define a call-by-name function\")\n  def placeOrderWithByNameParameter(orders: List[(String, Int, Double)])(exchangeRate: => Double): Double = {\n    var totalCost: Double = 0.0\n    orders.foreach {order =>\n      val costOfItem = order._2 * order._3 * exchangeRate\n      println(s\"Cost of ${order._2} ${order._1} = £$costOfItem\")\n      totalCost += costOfItem\n    }\n    totalCost\n  }\n\n\n\n  println(\"\\nStep 5: Define a simple USD to GBP function\")\n  val randomExchangeRate = new Random(10)\n  def usdToGbp: Double = {\n    val rate = randomExchangeRate.nextDouble()\n    println(s\"Fetching USD to GBP exchange rate = $rate\")\n    rate\n  }\n\n\n\n  println(\"\\nStep 6: How to call function with call-by-name parameter\")\n  println(s\"Total cost of order = £${placeOrderWithByNameParameter(listOrders)(usdToGbp)}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionCompositionAndThen_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn Function Composition Using AndThen – f(x) andThen g(x)\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-function-composition-andthen/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionCompositionAndThen_Tutorial extends App {\n\n\n  println(\"Step 1: Assume a pre-calculated total cost amount\")\n  val totalCost: Double = 10\n\n\n\n  println(\"\\nStep 2: How to define a val function to apply discount to total cost\")\n  val applyDiscountValFunction = (amount: Double) => {\n    println(\"Apply discount function\")\n    val discount = 2 // fetch discount from database\n    amount - discount\n  }\n\n\n\n  println(\"\\nStep 3: How to call a val function\")\n  println(s\"Total cost of 5 donuts with discount = ${applyDiscountValFunction(totalCost)}\")\n\n\n\n  println(\"\\nStep 4: How to define a val function to apply tax to total cost\")\n  val applyTaxValFunction = (amount: Double) => {\n    println(\"Apply tax function\")\n    val tax = 1 // fetch tax from database\n    amount + tax\n  }\n\n\n\n  println(\"\\nStep 5: How to call andThen on a val function\")\n  println(s\"Total cost of 5 donuts = ${ (applyDiscountValFunction andThen applyTaxValFunction)(totalCost) }\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionCompositionCompose_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn Function Composition Using Compose – f(x) compose g(x)\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-function-composition-compose/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionCompositionCompose_Tutorial extends App {\n\n  println(\"Step 1: Assume a pre-calculated total cost amount\")\n  val totalCost: Double = 10\n\n\n\n  println(\"\\nStep 2: How to define a val function to apply discount to total cost\")\n  val applyDiscountValFunction = (amount: Double) => {\n    println(\"Apply discount function\")\n    val discount = 2 // fetch discount from database\n    amount - discount\n  }\n\n\n\n  println(\"\\nStep 3: How to call a val function\")\n  println(s\"Total cost of 5 donuts with discount = ${applyDiscountValFunction(totalCost)}\")\n\n\n\n  println(\"\\nStep 4: How to define a val function to apply tax to total cost\")\n  val applyTaxValFunction = (amount: Double) => {\n    println(\"Apply tax function\")\n    val tax = 1 // fetch tax from database\n    amount + tax\n  }\n\n\n\n  println(\"\\nStep 5: How to call compose on a val function\")\n  println(s\"Total cost of 5 donuts = ${ (applyDiscountValFunction compose applyTaxValFunction)(totalCost) }\")\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionCurriedParameterGroups_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Function Currying With Parameter Groups\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-create-function-currying-parameter-groups/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionCurriedParameterGroups_Tutorial extends App {\n\n  println(\"Step 1: How to define function with curried parameter groups\")\n  def totalCost(donutType: String)(quantity: Int)(discount: Double): Double = {\n    println(s\"Calculating total cost for $quantity $donutType with ${discount * 100}% discount\")\n    val totalCost = 2.50 * quantity\n    totalCost - (totalCost * discount)\n  }\n\n\n\n  println(\"\\nStep 2: How to call a function with curried parameter groups\")\n  println(s\"Total cost = ${totalCost(\"Glazed Donut\")(10)(0.1)}\")\n\n\n\n  println(\"\\nStep 3: How to create a partially applied function from a function with curried parameter groups\")\n  val totalCostForGlazedDonuts = totalCost(\"Glazed Donut\") _\n\n\n\n  println(\"\\nStep 4: How to call a partially applied function\")\n  println(s\"Total cost for Glazed Donuts ${totalCostForGlazedDonuts(10)(0.1)}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionDefinedAsSymbols_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Functions As Symbols\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-functions-symbols/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionDefinedAsSymbols_Tutorial extends App {\n\n\n  println(\"Step 1: How to create and instantiate a class\")\n  val donutCostCalculator = new DonutCostCalculator()\n\n\n\n  println(\"\\nStep 2: How to call a function from an instantiated class\")\n  println(s\"Calling minusDiscount() function = ${donutCostCalculator.minusDiscount(10.5)}\")\n\n\n\n  println(\"\\nStep 4: How to call function whose name is just the symbol -\")\n  println(s\"Calling function - = ${donutCostCalculator.-(10.5)}\")\n\n\n\n  println(\"\\nStep 5: How to call a function using the operator style notation\")\n  println(s\"Calling function - with operator style notation = ${donutCostCalculator - 10.5}\")\n}\n\nclass DonutCostCalculator {\n\n  // We are hard-coding the totalCost value for simplicity.\n  val totalCost = 100\n\n  def minusDiscount(discount: Double): Double = {\n    totalCost - discount\n  }\n\n\n  // Step 3: How to define function whose name is just the symbol minus -\n  def -(discount: Double): Double = {\n    totalCost - discount\n  }\n\n\n  // Step 6: How to define function whose name is just the symbol +++\n  def +++(taxAmount: Double): Double = {\n    totalCost + taxAmount\n  }\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionHigherOrderAsParameters_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Higher Order Function - Function As Parameter\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-higher-order-function-parameter/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionHigherOrderAsParameters_Tutorial extends App {\n\n  println(\"Step 1: Review how to define function with curried parameter groups\")\n  def totalCost(donutType: String)(quantity: Int)(discount: Double): Double = {\n    println(s\"Calculating total cost for $quantity $donutType with ${discount * 100}% discount\")\n    val totalCost = 2.50 * quantity\n    totalCost - (totalCost * discount)\n  }\n\n\n\n  println(\"\\nStep 2: How to define a higher order function which takes another function as parameter\")\n  def totalCostWithDiscountFunctionParameter(donutType: String)(quantity: Int)(f: Double => Double): Double = {\n    println(s\"Calculating total cost for $quantity $donutType\")\n    val totalCost = 2.50 * quantity\n    f(totalCost)\n  }\n\n\n\n  println(\"\\nStep 3: How to call higher order function and pass an anonymous function as parameter\")\n  val totalCostOf5Donuts = totalCostWithDiscountFunctionParameter(\"Glazed Donut\")(5){totalCost =>\n    val discount = 2 // assume you fetch discount from database\n    totalCost - discount\n  }\n  println(s\"Total cost of 5 Glazed Donuts with anonymous discount function = $totalCostOf5Donuts\")\n\n\n\n  println(\"\\nStep 4: How to define and pass a function to a higher order function\")\n  def applyDiscount(totalCost: Double): Double = {\n    val discount = 2 // assume you fetch discount from database\n    totalCost - discount\n  }\n  println(s\"Total cost of 5 Glazed Donuts with discount function = ${totalCostWithDiscountFunctionParameter(\"Glazed Donut\")(5)(applyDiscount(_))}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionRecursiveTailCall_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\nimport scala.util.control.TailCalls._\n\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Tail Recursive Function - scala.util.control.TailCalls._\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-tail-recursive-function-scala-control-util-tailcalls/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionRecursiveTailCall_Tutorial extends App {\n\n\n  println(\"\\nStep 1: Review how to define a tail recursive function\")\n  @annotation.tailrec\n  def search(donutName: String, donuts: Array[String], index: Int): Option[Boolean] = {\n    if(donuts.length == index) {\n      None\n    } else if(donuts(index) == donutName) {\n      Some(true)\n    } else {\n      val nextIndex = index + 1\n      search(donutName, donuts, nextIndex)\n    }\n  }\n\n\n\n  println(\"\\nStep 2: Review how to call a tail recursive function\")\n  val arrayDonuts: Array[String] = Array(\"Vanilla Donut\", \"Strawberry Donut\", \"Plain Donut\", \"Glazed Donut\")\n  val found = search(\"Glazed Donut\", arrayDonuts, 0)\n  println(s\"Find Glazed Donut = $found\")\n\n\n\n  println(\"\\nStep 3: How to define a tail recursive function using scala.util.control.TailCalls._\")\n  def tailSearch(donutName: String, donuts: Array[String], index: Int): TailRec[Option[Boolean]] = {\n    if(donuts.length == index) {\n      done(None) // NOTE: done is imported from scala.util.control.TailCalls._\n    } else if(donuts(index) == donutName) {\n      done(Some(true))\n    } else {\n      val nextIndex = index + 1\n      tailcall(tailSearch(donutName, donuts, nextIndex)) // NOTE: tailcall is imported from scala.util.control.TailCalls._\n    }\n  }\n\n\n\n  println(\"\\nStep 4: How to call tail recursive function using scala.util.control.TailCalls._\")\n  val tailFound = tailcall(tailSearch(\"Glazed Donut\", arrayDonuts, 0))\n  println(s\"Find Glazed Donut using TailCall = ${tailFound.result}\") // NOTE: our returned value is wrapped so we need to get it by calling result\n\n  val tailNotFound = tailcall(tailSearch(\"Chocolate Donut\", arrayDonuts, 0))\n  println(s\"Find Chocolate Donut using TailCall = ${tailNotFound.result}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionRecursive_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Tail Recursive Function - @annotation.tailrec\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-tail-recursive-function-tailrec-annotation/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionRecursive_Tutorial extends App {\n\n  println(\"Step 1: How to define an Array of type String\")\n  val arrayDonuts: Array[String] = Array(\"Vanilla Donut\", \"Strawberry Donut\", \"Plain Donut\", \"Glazed Donut\")\n\n\n\n  println(\"\\nStep 2: How to define a tail recursive function\")\n  @annotation.tailrec\n  def search(donutName: String, donuts: Array[String], index: Int): Option[Boolean] = {\n    if(donuts.length == index) {\n      None\n    } else if(donuts(index) == donutName) {\n      Some(true)\n    } else {\n      val nextIndex = index + 1\n      search(donutName, donuts, nextIndex)\n    }\n  }\n\n\n\n  println(\"\\nStep 3: How to call a tail recursive function\")\n  val found = search(\"Glazed Donut\", arrayDonuts, 0)\n  println(s\"Find Glazed Donut = $found\")\n\n  val notFound = search(\"Chocolate Donut\", arrayDonuts, 0)\n  println(s\"Find Chocolate Donut = $notFound\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionTrampoline_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\nimport scala.util.control.TailCalls._\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Trampoline Tail Recursive Function Using scala.util.control.TailCalls\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-trampoline-tail-recursive-function/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionTrampoline_Tutorial extends App {\n\n  println(\"Step 1: How to define a trampoline function using scala.util.control.TailCalls\")\n  def verySweetDonut(donutList: List[String]): TailRec[Boolean] = {\n    println(s\"verySweetDonut function: donut list = $donutList\")\n    if (donutList.isEmpty) {\n      println(\"verySweetDonut function: donut list isEmpty, returning false\")\n      done(false)\n    } else {\n      if(Set(donutList.head).subsetOf(Set(\"Vanilla Donut\",\"Strawberry Donut\",\"Glazed Donut\"))) {\n        println(s\"verySweetDonut function: found donut list's head = ${donutList.head} to be VERY sweet, returning true\")\n        done(true)\n      } else {\n        println(s\"verySweetDonut function: donut list's head = ${donutList.head} is NOT VERY sweet, forwarding donut list's to notSweetDonut function\")\n        tailcall(notSweetDonut(donutList))\n      }\n    }\n  }\n\n\n\n  println(\"\\nStep 2: How to define a trampoline function using scala.util.control.TailCalls\")\n  def notSweetDonut(donutList: List[String]): TailRec[Boolean] = {\n    println(s\"notSweetDonut function: with donut list = $donutList\")\n    if (donutList.isEmpty) {\n      println(\"notSweetDonut function: donut list isEmpty, returning false\")\n      done(false)\n    } else {\n      println(s\"notSweetDonut function: donut list's head = ${donutList.head} is NOT sweet, forwarding donut list's tail to verySweetDonut function\")\n      tailcall(verySweetDonut(donutList.tail))\n    }\n  }\n\n\n\n  println(\"\\nStep 3: How to call a trampoline tail recursive function\")\n  val donutList: List[String] = List(\"Plain Donut\", \"Strawberry Donut\", \"Plain Donut\", \"Glazed Donut\")\n  val foundVerySweetDonut = tailcall(verySweetDonut(donutList)).result\n  println(s\"Found very sweet donut = $foundVerySweetDonut\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWhichIsImplicit_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Implicit Function\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-implicit-function/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionWhichIsImplicit_Tutorial extends App {\n\n\n  println(\"Step 1: How to create a wrapper String class which will extend the String type\")\n  class DonutString(s: String) {\n\n    def isFavoriteDonut: Boolean = s == \"Glazed Donut\"\n\n  }\n\n\n\n  println(\"\\nStep 2: How to create an implicit function to convert a String to the wrapper String class\")\n  object DonutConverstions {\n    implicit def stringToDonutString(s: String) = new DonutString(s)\n  }\n\n\n\n  println(\"\\nStep 3: How to import the String conversion so that it is in scope\")\n  import DonutConverstions._\n\n\n\n  println(\"\\nStep 4: How to create String values\")\n  val glazedDonut = \"Glazed Donut\"\n  val vanillaDonut = \"Vanilla Donut\"\n\n\n\n  println(\"\\nStep 5: How to access the custom String function called isFavaoriteDonut\")\n  println(s\"Is Glazed Donut my favorite Donut  = ${glazedDonut.isFavoriteDonut}\")\n  println(s\"Is Vanilla Donut my favorite Donut = ${vanillaDonut.isFavoriteDonut}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWhichIsNested.scala",
    "content": "package com.allaboutscala.chapter.three\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Nested Function\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-nested-function/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionWhichIsNested extends App {\n\n  println(\"Step 1: How to define a function\")\n  def checkDonutAvailability(donutName: String): Boolean = {\n    // retrieve donut list that is currently in stock\n    val listDonutsFromStock: List[String] = List(\"Vanilla Donut\", \"Strawberry Donut\", \"Plain Donut\", \"Glazed Donut\")\n\n    val iDonutInStock = (donutName.nonEmpty && donutName.length > 0) && (listDonutsFromStock contains donutName)\n\n    iDonutInStock\n  }\n\n\n\n  println(\"\\nStep 2: How to call a function\")\n  println(s\"Calling checkDonutAvailability with Vanilla Donut = ${checkDonutAvailability(\"Vanilla Donut\")}\")\n\n\n\n  println(\"\\nStep 3: How to define a Nested Function\")\n  def checkDonutAvailabilityWithNestedFunction(donutName: String): Boolean = {\n    // retrieve donut list that is currently in stock\n    val listDonutsFromStock = List[String](\"Vanilla Donut\", \"Strawberry Donut\", \"Plain Donut\", \"Glazed Donut\")\n\n    // validate the donutName parameter by some business logic\n    val validate = (name: String) => {\n      name.nonEmpty && name.length > 0\n    }\n\n    // first run validate and then check if we have a matching donut from our list\n    val isDonutInStock = validate(donutName) && (listDonutsFromStock contains donutName)\n\n    isDonutInStock\n  }\n\n\n\n  println(\"\\nStep 4: How to call a Nested Function\")\n  println(s\"Calling checkDonutAvailabilityWithNestedFunction with Vanilla Donut = ${checkDonutAvailabilityWithNestedFunction(\"Vanilla Donut\")}\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWhichIsPartial_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Partial Function Using the PartialFunction Trait\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-partial-function-trait/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionWhichIsPartial_Tutorial extends App {\n\n  println(\"Step 1: Review of Pattern Matching in Scala\")\n  val donut = \"Glazed Donut\"\n  val tasteLevel = donut match {\n    case \"Glazed Donut\" | \"Strawberry Donut\" => \"Very tasty\"\n    case \"Plain Donut\" => \"Tasty\"\n    case _  => \"Tasty\"\n  }\n  println(s\"Taste level of $donut = $tasteLevel\")\n\n\n\n  println(\"\\nStep 2: How to define a Partial Function named isVeryTasty\")\n  val isVeryTasty: PartialFunction[String, String] = {\n    case \"Glazed Donut\" | \"Strawberry Donut\" => \"Very Tasty\"\n  }\n\n\n\n  println(\"\\nStep 3: How to call the Partial Function named isVeryTasty\")\n  println(s\"Calling partial function isVeryTasty = ${isVeryTasty(\"Glazed Donut\")}\")\n  // NOTE: you will get scala.MatchError\n\n\n\n  println(\"\\nStep 4: How to define PartialFunction named isTasty and unknownTaste\")\n  val isTasty: PartialFunction[String, String] = {\n    case \"Plain Donut\" => \"Tasty\"\n  }\n\n  val unknownTaste: PartialFunction[String, String] = {\n    case donut @ _ => s\"Unknown taste for donut = $donut\"\n  }\n\n\n\n  println(\"\\nStep 5: How to compose PartialFunction using orElse\")\n  val donutTaste = isVeryTasty orElse isTasty orElse unknownTaste\n  println(donutTaste(\"Glazed Donut\"))\n  println(donutTaste(\"Plain Donut\"))\n  println(donutTaste(\"Chocolate Donut\"))\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWhichIsPolymorphicWithGenericReturnType_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Polymorphic Function With Generic Return Type\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-polymorphic-function-generic-return-type/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionWhichIsPolymorphicWithGenericReturnType_Tutorial extends App {\n\n  println(\"\\nStep 1: Review how to define a generic typed function which will specify the type of its parameter\")\n  def applyDiscount[T](discount: T) {\n    discount match {\n      case d: String =>\n        println(s\"Lookup percentage discount in database for $d\")\n\n      case d: Double =>\n        println(s\"$d discount will be applied\")\n\n      case _ =>\n        println(\"Unsupported discount type\")\n    }\n  }\n\n\n\n  println(\"\\nStep 2: Review how to call a function which has typed parameters\")\n  applyDiscount[String](\"COUPON_123\")\n  applyDiscount[Double](10)\n\n\n\n  println(\"\\nStep 3: How to define a generic polymorphic function which also has a generic return type\")\n  def applyDiscountWithReturnType[T](discount: T): Seq[T] = {\n    discount match {\n      case d: String =>\n        println(s\"Lookup percentage discount in database for $d\")\n        Seq[T](discount)\n\n      case d: Double =>\n        println(s\"$d discount will be applied\")\n        Seq[T](discount)\n\n      case d @ _ =>\n        println(\"Unsupported discount type\")\n        Seq[T](discount)\n    }\n  }\n\n\n\n  println(\"\\nStep 4: How to call a generic polymorphic function which also has a generic return type\")\n  println(s\"Result of applyDiscountWithReturnType with String parameter = ${applyDiscountWithReturnType[String](\"COUPON_123\")}\")\n\n  println()\n  println(s\"Result of applyDiscountWithReturnType with Double parameter = ${applyDiscountWithReturnType[Double](10.5)}\")\n\n  println()\n  println(s\"Result of applyDiscountWithReturnType with Char parameter = ${applyDiscountWithReturnType[Char]('U')}\")\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWhichIsTyped_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Typed Function\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-typed-function/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionWhichIsTyped_Tutorial extends App {\n\n\n  println(\"Step 1: How to define a function which takes a String parameter\")\n  def applyDiscount(couponCode: String) {\n    println(s\"Lookup percentage discount in database for $couponCode\")\n  }\n\n\n\n  println(\"\\nStep 2: How to define a function which takes a parameter of type Double\")\n  def applyDiscount(percentageDiscount: Double) {\n    println(s\"$percentageDiscount discount will be applied\")\n  }\n\n\n\n  println(\"\\nStep 3: Calling applyDiscount function with String or Double parameter types\")\n  applyDiscount(\"COUPON_1234\")\n  applyDiscount(10)\n\n\n\n  println(\"\\nStep 4: How to define a generic typed function which will specify the type of its parameter\")\n  def applyDiscount[T](discount: T) {\n    discount match {\n      case d: String =>\n        println(s\"Lookup percentage discount in database for $d\")\n\n      case d: Double =>\n        println(s\"$d discount will be applied\")\n\n      case _ =>\n        println(\"Unsupported discount type\")\n    }\n  }\n\n\n\n  println(\"\\nStep 5: How to call a function which has typed parameters\")\n  applyDiscount[String](\"COUPON_123\")\n  applyDiscount[Double](10)\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWithCallbackParameter_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Function With Callback Parameter\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-function-callback-parameter/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionWithCallbackParameter_Tutorial extends App {\n\n  println(\"Step 1: How to define a function with a callback parameter\")\n  def printReport(sendEmailCallback: () => Unit) {\n    println(\"Printing report ... started\")\n    // look up some data in database and create a report\n    println(\"Printing report ... finished\")\n    sendEmailCallback()\n  }\n\n\n\n  println(\"\\nStep 2: How to call a function which has a callback parameter\")\n  printReport(() =>\n    println(\"Sending email ... finished\")\n  )\n\n\n\n  println(\"\\nStep 3: How to call a function without providing its callback parameter\")\n  // printReport() // You get compile time error\n  printReport(() => {}) // Not that elegant.\n\n\n\n  println(\"\\nStep 4: How to define a function with an Option callback\")\n  def printReportWithOptionCallback(sendEmailCallback: Option[() => Unit] = None) {\n    println(\"Printing report ... started\")\n    // look up some data in database and create a report\n    println(\"Printing report ... finished\")\n    sendEmailCallback.map(callback => callback())\n  }\n\n\n\n  println(\"\\nStep 5: How to call a function without providing its callback parameter\")\n  printReportWithOptionCallback() // more elegant\n\n\n\n  println(\"\\nStep 6: How to call a function with Option callback parameter\")\n  printReportWithOptionCallback(Some(() =>\n    println(\"Sending email wrapped in Some() ... finished\")\n  ))\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWithImplicitParameters_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Function With Implicit Parameter\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-function-implicit-parameter/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionWithImplicitParameters_Tutorial extends App {\n\n  println(s\"Step 1: How to define a function with an implicit parameter\")\n  def totalCost(donutType: String, quantity: Int)(implicit discount: Double): Double = {\n    println(s\"Calculating the price for $quantity $donutType\")\n    val totalCost = 2.50 * quantity * (1 - discount)\n    totalCost\n  }\n\n\n\n  println(\"\\nStep 2: How to define an implicit value\")\n  implicit val discount: Double = 0.1\n  println(s\"All customer will receive a ${discount * 100}% discount\")\n\n\n\n  println(\"\\nStep 3: How to call a function which has an implicit parameter\")\n  println(s\"\"\"Total cost with discount of 5 Glazed Donuts = ${totalCost(\"Glazed Donut\", 5)}\"\"\")\n\n\n\n  println(\"\\nStep 4: How to define a function which takes multiple implicit parameters\")\n  def totalCost2(donutType: String, quantity: Int)(implicit discount: Double, storeName: String): Double = {\n    println(s\"[$storeName] Calculating the price for $quantity $donutType\")\n    val totalCost = 2.50 * quantity * (1 - discount)\n    totalCost\n  }\n\n\n\n  println(\"\\nStep 5: How to call a function which takes multiple implicit parameters\")\n  implicit val storeName: String = \"Tasty Donut Store\"\n  println(s\"\"\"Total cost with discount of 5 Glazed Donuts = ${totalCost2(\"Glazed Donut\", 5)}\"\"\")\n\n\n\n  println(\"\\nStep 6: How to manually pass-through implicit parameters\")\n  println(s\"\"\"Total cost with discount of 5 Glazed Donuts, manually passed-through = ${totalCost2(\"Glazed Donut\", 5)(0.1, \"Scala Donut Store\")}\"\"\")\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWithOptionParameters_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Use Option In Function Parameters\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-use-option-function-parameters/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionWithOptionParameters_Tutorial extends App {\n\n\n  println(\"Step 1: How to define an Option in a function parameter\")\n  def calculateDonutCost(donutName: String, quantity: Int, couponCode: Option[String]): Double = {\n    println(s\"Calculating cost for $donutName, quantity = $quantity\")\n\n    couponCode match {\n      case Some(coupon) =>\n        val discount = 0.1 // Let's simulate a 10% discount\n        val totalCost = 2.50 * quantity * (1 - discount)\n        totalCost\n\n      case None => 2.50 * quantity\n    }\n  }\n\n\n\n  println(\"\\nStep 2: How to call a function which has an Option parameter\")\n  println(s\"\"\"Total cost = ${calculateDonutCost(\"Glazed Donut\", 5, None)}\"\"\")\n\n\n\n  println(\"\\nStep 3: How to assign a default value to an Option parameter\")\n  def calculateDonutCostWithDefaultOptionValue(donutName: String, quantity: Int, couponCode: Option[String] = None): Double = {\n    println(s\"Calculating cost for $donutName, quantity = $quantity\")\n\n    couponCode match{\n      case Some(coupon) =>\n        val discount = 0.1 // Let's simulate a 10% discount\n        val totalCost = 2.50 * quantity * (1 - discount)\n        totalCost\n\n      case _ => 2.50 * quantity\n    }\n  }\n\n\n\n  println(\"\\nStep 4: How to call a function which has an Option parameter with a default value\")\n  println(s\"\"\"Total cost = ${calculateDonutCostWithDefaultOptionValue(\"Glazed Donut\", 5)}\"\"\")\n  println(s\"\"\"Total cost with discount = ${calculateDonutCostWithDefaultOptionValue(\"Glazed Donut\", 5, Some(\"COUPON_1234\"))}\"\"\")\n\n\n\n  println(s\"\\nTip 1: Use the map function to extract a valid Option value\")\n  val favoriteDonut: Option[String] = Some(\"Glazed Donut\")\n  favoriteDonut.map(d => println(s\"Favorite donut = $d\"))\n\n  val leastFavoriteDonut: Option[String] = None\n  leastFavoriteDonut.map(d => println(s\"Least Favorite donut = $d\"))\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWithOptionReturnType_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Function With Option Return Type\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-function-return-type/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionWithOptionReturnType_Tutorial extends App {\n\n\n  println(s\"Step 1: Define a function which returns an Option of type String\")\n  def dailyCouponCode(): Option[String] = {\n    // look up in database if we will provide our customers with a coupon today\n    val couponFromDb = \"COUPON_1234\"\n    Option(couponFromDb).filter(_.nonEmpty)\n  }\n\n\n\n  println(s\"\\nStep 2: Call function with Option return type using getOrElse\")\n  val todayCoupon: Option[String] = dailyCouponCode()\n  println(s\"Today's coupon code = ${todayCoupon.getOrElse(\"No Coupon's Today\")}\")\n\n\n\n  println(s\"\\nStep 3: Call function with Option return type using pattern matching\")\n  dailyCouponCode() match {\n    case Some(couponCode) => println(s\"Today's coupon code = $couponCode\")\n    case None => println(s\"Sorry there is no coupon code today!\")\n  }\n\n\n\n  println(s\"\\nStep 4: Call function with Option return type using map\")\n  dailyCouponCode().map(couponCode => println(s\"Today's coupon code = $couponCode\"))\n\n\n\n  println(\"\\nStep 5: Review function from previous tutorial which has an Option parameter\")\n  def calculateDonutCost(donutName: String, quantity: Int, couponCode: Option[String]): Double = {\n    println(s\"Calculating cost for $donutName, quantity = $quantity\")\n\n    couponCode match {\n      case Some(coupon) =>\n        val discount = 0.1 // Let's simulate a 10% discount\n      val totalCost = 2.50 * quantity * (1 - discount)\n        totalCost\n\n      case None => 2.50 * quantity\n    }\n  }\n\n  // apply daily coupon code if we have one\n  println(s\"\"\"Total cost with daily coupon code = ${calculateDonutCost(\"Glazed Donut\", 5, dailyCouponCode())}\"\"\")\n\n\n\n  println(s\"\\nTip - 1: Call function with Option return type using fold\")\n  val todayCouponUsingFold: String = dailyCouponCode().fold(\"No Coupon Available\")(couponCode => couponCode)\n  println(s\"Today's coupon code = $todayCouponUsingFold\")\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWithParameters_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\n/**\n  * Created by Nadim Bahadoor on 26/06/2016.\n  *\n  *  Tutorial: Learn How To Create Function With Parameters\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-function-parameters/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionWithParameters_Tutorial extends App {\n\n  println(\"Step 1: How to define function with parameters\")\n  def calculateDonutCost(donutName: String, quantity: Int): Double = {\n    println(s\"Calculating cost for $donutName, quantity = $quantity\")\n\n    // make some calculations ...\n    2.50 * quantity\n  }\n\n\n\n  println(\"\\nStep 2: How to call a function with parameters\")\n  val totalCost = calculateDonutCost(\"Glazed Donut\", 5)\n  println(s\"Total cost of donuts = $totalCost\")\n\n\n\n  println(\"\\nStep 3: How to add default values to function parameters\")\n  def calculateDonutCost(donutName: String, quantity: Int, couponCode: String = \"NO CODE\"): Double = {\n    println(s\"Calculating cost for $donutName, quantity = $quantity, couponCode = $couponCode\")\n\n    // make some calculations ...\n    2.50 * quantity\n  }\n\n\n\n  println(\"\\nStep 4: How to call a function with parameters that has default values\")\n  val totalCostWithDiscount = calculateDonutCost(\"Glazed Donut\", 4, \"COUPON_12345\")\n  val totalCostWithoutDiscount = calculateDonutCost(\"Glazed Donut\", 4)\n\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/three/FunctionWithVariableArguments_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.three\n\n/**\n  * Created by Nadim Bahadoor on 28/06/2016.\n  *\n  *  Tutorial: Learn How To Create Variable Argument Function\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-3-beginner-tutorial-using-functions-scala/scala-tutorial-learn-create-variable-argument-function/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject FunctionWithVariableArguments_Tutorial extends App {\n\n  println(\"Step 1: How to define function which takes variable number of arguments\")\n  def printReport(names: String*) {\n    println(s\"\"\"Donut Report = ${names.mkString(\" - \")}\"\"\")\n  }\n\n\n\n  println(\"\\nStep 2: How to call function which takes variable number of String arguments\")\n  printReport(\"Glazed Donut\", \"Strawberry Donut\", \"Vanilla Donut\")\n  printReport(\"Chocolate Donut\")\n\n\n\n  println(\"\\nStep 3: How to pass a List to a function with variable number of arguments\")\n  val listDonuts: List[String] = List(\"Glazed Donut\", \"Strawberry Donut\", \"Vanilla Donut\")\n  printReport(listDonuts: _*)\n\n\n\n  println(\"\\nStep 4: How to pass a Sequence to a function with variable number of arguments\")\n  val seqDonuts: Seq[String] = Seq(\"Chocolate Donut\", \"Plain Donut\")\n  printReport(seqDonuts: _*)\n\n\n\n  println(\"\\nStep 5: How to pass an Array to a function with variable number of arguments\")\n  val arrDonuts: Array[String] = Array(\"Coconut Donut\")\n  printReport(arrDonuts: _*)\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_01/VariablesBasics_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.two.tutorial_01\n\n/**\n  * Created by Nadim Bahadoor on 07/06/2016.\n  *\n  * Tutorial: Scala Basic Tutorial – How To Declare Variables And Types\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-basic-tutorial-declare-variables-types/ Tutorial]]\n  *\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject VariablesBasics_Tutorial extends App {\n\n  println(\"Step 1: Immutable variable\")\n  val donutsToBuy: Int = 5\n\n//    donutsToBuy = 10 // you will get compile error because donutToBuy is immutable\n\n\n\n  println(\"\\nStep 2: Mutable variable\")\n  var favoriteDonut: String = \"Glazed Donut\"\n  favoriteDonut = \"Vanilla Donut\"\n\n\n\n  println(\"\\nStep 3: lazy initialization\")\n  lazy val donutService = \"initialize some donut service\"\n\n\n\n  println(\"\\nStep 4: Scala Types\")\n  val donutsBought: Int = 5\n\n  val bigNumberOfDonuts: Long = 100000000L\n\n  val smallNumberOfDonuts: Short = 1\n\n  val priceOfDonut: Double = 2.50\n\n  val donutPrice: Float = 2.50f\n\n  val donutStoreName: String = \"Allaboutscala Donut Store\"\n\n  val donutByte: Byte = 0xa\n\n  val donutFirstLetter: Char = 'D'\n\n  val nothing: Unit = ()\n\n\n\n\n  println(\"\\nStep 5: Declare a variable without initialization\")\n  var leastFavoriteDonut: String = _\n\n  leastFavoriteDonut = \"Plain Donut\"\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_02/StringInterpolation_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.two.tutorial_02\n\n/**\n  * Created by Nadim Bahadoor on 08/06/2016.\n  *\n  * Tutorial: Scala String Interpolation – Print And Format Variables\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-string-interpolation-print-format-variables/ Tutorial]]\n  *\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject StringInterpolation_Tutorial extends App {\n\n  println(\"Step 1: Using String interpolation to print a variable\")\n  val favoriteDonut: String = \"Glazed Donut\"\n  println(s\"My favorite donut = $favoriteDonut\")\n\n\n\n  println(\"\\nStep 2: Using String interpolation on object properties\")\n  case class Donut(name: String, tasteLevel: String)\n\n  val favoriteDonut2: Donut = Donut(\"Glazed Donut\", \"Very Tasty\")\n  println(s\"My favorite donut name = ${favoriteDonut2.name}, tasteLevel = ${favoriteDonut2.tasteLevel}\")\n\n\n\n  println(\"\\nStep 3: Using String interpolation to evaluate expressions\")\n  val qtyDonutsToBuy: Int = 10\n  println(s\"Are we buying 10 donuts = ${qtyDonutsToBuy == 10}\")\n\n\n\n  println(\"\\nStep 4: Using String interpolation for formatting text\")\n  val donutName: String = \"Vanilla Donut\"\n  val donutTasteLevel: String = \"Tasty\"\n  println(f\"$donutName%20s $donutTasteLevel\")\n\n\n\n  println(\"\\nStep 5: Using f interpolation to format numbers\")\n  val donutPrice: Double = 2.50\n  println(s\"Donut price = $donutPrice\")\n  println(f\"Formatted donut price = $donutPrice%.2f\")\n\n\n\n  println(\"\\nStep 6: Using raw interpolation\")\n  println(raw\"Favorite donut\\t$donutName\")\n\n\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_03/EscapeCharacter_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.two.tutorial_03\n\n/**\n  * Created by Nadim Bahadoor on 09/06/2016.\n  *\n  * Tutorial: Scala – How To Escape Characters And Create Multi-line String\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-escape-characters-create-multi-line-string/ Tutorial]]\n  *\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject EscapeCharacter_Tutorial extends App {\n\n\n\n  println(\"Step 1: How to escape a Json String\")\n//  val donutJson: String =\"{\"donut_name\":\"Glazed Donut\",\"taste_level\":\"Very Tasty\",\"price\":2.50}\"\n\n\n\n  println(\"\\nStep 2: Using backslash to escpae quotes\")\n  val donutJson2: String = \"{\\\"donut_name\\\":\\\"Glazed Donut\\\",\\\"taste_level\\\":\\\"Very Tasty\\\",\\\"price\\\":2.50}\"\n  println(s\"donutJson2 = $donutJson2\")\n\n\n\n  println(\"\\nStep 3: Using triple quotes \\\"\\\"\\\" to escape characters\")\n  val donutJson3: String = \"\"\"{\"donut_name\":\"Glazed Donut\",\"taste_level\":\"Very Tasty\",\"price\":2.50}\"\"\"\n  println(s\"donutJson3 = $donutJson3\")\n\n\n  println(\"\\nStep 4:  Creating multi-line text using stripMargin\")\n  val donutJson4: String =\n    \"\"\"\n      |{\n      |\"donut_name\":\"Glazed Donut\",\n      |\"taste_level\":\"Very Tasty\",\n      |\"price\":2.50\n      |}\n    \"\"\".stripMargin\n  println(s\"donutJson4 = $donutJson4\")\n\n\n\n  println(\"\\nTip:  stripMargin using a different character\")\n  val donutJson5: String =\n    \"\"\"\n      #{\n      #\"donut_name\":\"Glazed Donut\",\n      #\"taste_level\":\"Very Tasty\",\n      #\"price\":2.50\n      #}\n    \"\"\".stripMargin('#')\n  println(s\"donutJson5 = $donutJson4\")\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_04/VariablesTypeInference_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.two.tutorial_04\n\n/**\n  * Created by Nadim Bahadoor on 10/06/2016.\n  *\n  * Tutorial: An Overview Of Scala Type Inference\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-overview-scala-type-inference/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject VariablesTypeInference_Tutorial extends App {\n\n\n  println(\"Step 1: Immutable variable\")\n  val donutsToBuy: Int = 5\n\n  val donutsBought = 5\n\n\n\n  println(\"\\nStep 2: Scala Types\")\n  val donutsBoughtToday = 5\n\n  val bigNumberOfDonuts = 100000000L\n\n  val smallNumberOfDonuts = 1\n\n  val priceOfDonut = 2.50\n\n  val donutPrice = 2.50f\n\n  val donutStoreName = \"Allaboutscala Donut Store\"\n\n  val donutByte = 0xa\n\n  val donutFirstLetter = 'D'\n\n  val nothing = ()\n\n\n\n  println(\"\\nStep 3: Using Scala compiler to convert from one data type to another\")\n  val numberOfDonuts: Short = 1\n\n  val minimumDonutsToBuy: Int = numberOfDonuts\n\n\n\n  println(\"\\nStep 4: User driven conversion from one data type to another \")\n  // NB: You cannot convert from an Int to a String\n  // val minimumDonutsToSell: String = numberOfDonuts\n\n  val minimumDonutsToSell: String = numberOfDonuts.toString()\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_05/If_Else_Expression_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.two.tutorial_05\n\n/**\n  * Created by Nadim Bahadoor on 13/06/2016.\n  *\n  * Tutorial: How To Use If Else Statement And Expression\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-use-if-else-statement-expression/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject If_Else_Expression_Tutorial extends App {\n\n  println(\"Step 1: Using if clause as a statement\")\n  val numberOfPeople = 20\n  val donutsPerPerson = 2\n\n  if(numberOfPeople > 10)\n    println(s\"Number of donuts to buy = ${numberOfPeople * donutsPerPerson}\")\n\n\n\n  println(s\"\\nStep 2: Using if and else clause as a statement\")\n  val defaultDonutsToBuy = 8\n\n  if(numberOfPeople > 10)\n    println(s\"Number of donuts to buy = ${numberOfPeople * donutsPerPerson}\")\n  else\n    println(s\"Number of donuts to buy = $defaultDonutsToBuy\")\n\n\n\n  println(\"\\nStep 3: Using if, else if, and else clause as a statement\")\n  if(numberOfPeople > 10) {\n    println(s\"Number of donuts to buy = ${numberOfPeople * donutsPerPerson}\")\n  } else if (numberOfPeople == 0) {\n    println(\"Number of people is zero.\")\n    println(\"No need to buy donuts.\")\n  } else {\n    println(s\"Number of donuts to buy = $defaultDonutsToBuy\")\n  }\n\n\n\n  println(\"\\nStep 4: Using if and else clause as expression\")\n  val numberOfDonutsToBuy = if(numberOfPeople > 10) (numberOfPeople * donutsPerPerson) else defaultDonutsToBuy\n  println(s\"Number of donuts to buy = $numberOfDonutsToBuy\")\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_06/ForLoop_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.two.tutorial_06\n\n/**\n  * Created by Nadim Bahadoor on 14/06/2016.\n  *\n  * Tutorial: Learn How To Use For Comprehension\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-learn-use-for-comprehension/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject ForLoop_Tutorial extends App {\n\n\n  println(\"Step 1: A simple for loop from 1 to 5 inclusive\")\n  for(numberOfDonuts <- 1 to 5){\n    println(s\"Number of donuts to buy = $numberOfDonuts\")\n  }\n\n\n\n  println(\"\\nStep 2: A simple for loop from 1 to 5, where 5 is NOT inclusive\")\n  for(numberOfDonuts <- 1 until 5){\n    println(s\"Number of donuts to buy = $numberOfDonuts\")\n  }\n\n\n\n  println(\"\\nStep 3: Filter values using if conditions in for loop\")\n  val donutIngredients = List(\"flour\", \"sugar\", \"egg yolks\", \"syrup\", \"flavouring\")\n  for(ingredient <- donutIngredients if ingredient == \"sugar\"){\n    println(s\"Found sweetening ingredient = $ingredient\")\n  }\n\n\n\n  println(\"\\nStep 4: Filter values using if conditions in for loop and return the result back using the yield keyword\")\n  val sweeteningIngredients = for {\n    ingredient <- donutIngredients\n    if (ingredient == \"sugar\" || ingredient == \"syrup\")\n  } yield ingredient\n  println(s\"Sweetening ingredients = $sweeteningIngredients\")\n\n\n\n  println(\"\\nStep 5: Using for comprehension to loop through 2-Dimensional array\")\n  val twoDimensionalArray = Array.ofDim[String](2,2)\n  twoDimensionalArray(0)(0) = \"flour\"\n  twoDimensionalArray(0)(1) = \"sugar\"\n  twoDimensionalArray(1)(0) = \"egg\"\n  twoDimensionalArray(1)(1) = \"syrup\"\n\n  for { x <- 0 until 2\n        y <- 0 until 2\n  } println(s\"Donut ingredient at index ${(x,y)} = ${twoDimensionalArray(x)(y)}\")\n\n\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_07/Range_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.two.tutorial_07\n\n/**\n  * Created by Nadim Bahadoor on 15/06/2016.\n  *\n  * Tutorial: Learn How To Use Range (Inclusive, Exclusive)\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-learn-use-range-inclusive-exclusive/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Range_Tutorial extends App {\n\n  println(\"Step 1: Create a simple numeric range from 1 to 5 inclusive\")\n  val from1To5 = 1 to 5\n  println(s\"Range from 1 to 5 inclusive = $from1To5\")\n\n\n\n  println(\"\\nStep 2: Create a numeric range from 1 to 5 but excluding the last integer number 5\")\n  val from1Until5 = 1 until 5\n  println(s\"Range from 1 until 5 where 5 is excluded = $from1Until5\")\n\n\n\n  println(\"\\nStep 3: Create a numeric range from 0 to 10 but increment with multiples of 2\")\n  val from0To10By2 = 0 to 10 by 2\n  println(s\"Range from 0 to 10 with multiples of 2 = $from0To10By2\")\n\n\n\n  println(\"\\nStep 4: Create an alphabetical range to represent letter a to z\")\n  val alphabetRangeFromAToZ = 'a' to 'z'\n  println(s\"Range of alphabets from a to z = $alphabetRangeFromAToZ\")\n\n\n\n  println(s\"\\nStep 5: Character ranges with user specified increment\")\n  val alphabetRangeFromAToZBy2 = 'a' to 'z' by 2\n  println(s\"Range of every other alphabet = $alphabetRangeFromAToZBy2\")\n\n\n\n  println(\"\\nStep 6: Storing our ranges into collections\")\n  val listFrom1To5 = (1 to 5).toList\n  println(s\"Range to list = ${listFrom1To5.mkString(\" \")}\")\n\n  val setFrom1To5 = (1 to 5).toSet\n  println(s\"Range to set = ${setFrom1To5.mkString(\" \")}\")\n\n  val sequenceFrom1To5 = (1 to 5).toSeq\n  println(s\"Range to sequence = ${sequenceFrom1To5.mkString(\" \")}\")\n\n  val arrayFrom1To5 = (1 to 5).toArray\n  println(s\"Range to array = `${arrayFrom1To5.mkString(\" \")}\")\n\n\n\n  // Tip:\n  // - To print every element in the array variable called arrayFrom1To5\n  arrayFrom1To5.foreach(print(_))\n\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_08/WhileLoop_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.two.tutorial_08\n\n/**\n  * Created by Nadim Bahadoor on 16/06/2016.\n  *\n  * Tutorial: Learn How To Use While And Do While Loop\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-learn-how-to-use-while-and-do-while-loop/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject WhileLoop_Tutorial extends App {\n\n  println(\"Step 1: How to use while loop in Scala\")\n  var numberOfDonutsToBake = 10\n  while (numberOfDonutsToBake > 0) {\n    println(s\"Remaining donuts to be baked = $numberOfDonutsToBake\")\n    numberOfDonutsToBake -= 1\n  }\n\n\n\n  println(\"\\nStep 2: How to use do while loop in Scala\")\n  var numberOfDonutsBaked = 0\n  do {\n    numberOfDonutsBaked += 1\n    println(s\"Number of donuts baked = $numberOfDonutsBaked\")\n  } while (numberOfDonutsBaked < 5)\n\n\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_09/PatternMatching_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.two.tutorial_09\n\n/**\n  * Created by Nadim Bahadoor on 17/06/2016.\n  *\n  *  Tutorial: Learn How To Use Pattern Matching\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-learn-how-to-use-pattern-matching/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject PatternMatching_Tutorial extends App {\n\n  println(\"Step 1: Pattern matching 101 - a very basic example\")\n  val donutType = \"Glazed Donut\"\n  donutType match {\n    case \"Glazed Donut\" => println(\"Very tasty\")\n    case \"Plain Donut\"  => println(\"Tasty\")\n  }\n\n\n\n  println(\"\\nStep 2: Pattern matching and return the result\")\n  val tasteLevel = donutType match {\n    case \"Glazed Donut\" => \"Very tasty\"\n    case \"Plain Donut\"  => \"Tasty\"\n  }\n  println(s\"Taste level of $donutType = $tasteLevel\")\n\n\n\n  println(\"\\nStep 3: Pattern matching using the wildcard operator\")\n  val tasteLevel2 = donutType match {\n    case \"Glazed Donut\" => \"Very tasty\"\n    case \"Plain Donut\"  => \"Tasty\"\n    case _              => \"Tasty\"\n  }\n  println(s\"Taste level of $donutType = $tasteLevel2\")\n\n\n\n  println(\"\\nStep 4: Pattern matching with two or more items on the same condition\")\n  val tasteLevel3 = donutType match {\n    case \"Glazed Donut\" | \"Strawberry Donut\" => \"Very tasty\"\n    case \"Plain Donut\" => \"Tasty\"\n    case _  => \"Tasty\"\n  }\n  println(s\"Taste level of $donutType = $tasteLevel3\")\n\n\n\n  println(\"\\nStep 5; Pattern matching and using if expressions in the case clause\")\n  val tasteLevel4 = donutType match {\n    case donut if (donut.contains(\"Glazed\") || donut.contains(\"Strawberry\")) => \"Very tasty\"\n    case \"Plain Donut\"  => \"Tasty\"\n    case _  => \"Tasty\"\n  }\n  println(s\"Taste level of $donutType = $tasteLevel4\")\n\n\n\n  println(\"\\nStep 6: Pattern matching by types\")\n  val priceOfDonut: Any = 2.50\n  val priceType = priceOfDonut match {\n    case price: Int     => \"Int\"\n    case price: Double  => \"Double\"\n    case price: Float   => \"Float\"\n    case price: String  => \"String\"\n    case price: Boolean => \"Boolean\"\n    case price: Char    => \"Char\"\n    case price: Long    => \"Long\"\n  }\n  println(s\"Donut price type = $priceType\")\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_10/Tuples_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.two.tutorial_10\n\n/**\n  * Created by Nadim Bahadoor on 18/06/2016.\n  *\n  *  Tutorial: Learn How To Use Tuples (Pattern Match)\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-learn-how-to-use-tuples-pattern-match/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject Tuples_Tutorial extends App {\n\n\n  println(\"Step 1: Using Tuple2 to store 2 data points\")\n  val glazedDonutTuple = Tuple2(\"Glazed Donut\", \"Very Tasty\")\n  println(s\"Glazed Donut with 2 data points = $glazedDonutTuple\")\n\n\n\n  println(\"\\nStep 2: Access each element in tuple\")\n  val donutType = glazedDonutTuple._1\n  val donutTasteLevel = glazedDonutTuple._2\n  println(s\"$donutType taste level is $donutTasteLevel\")\n\n\n\n  println(\"\\nStep 3: Using TupleN classes to store more than 2 data points\")\n  val glazedDonut = Tuple3(\"Glazed Donut\", \"Very Tasty\", 2.50)\n  println(s\"${glazedDonut._1} taste leve is ${glazedDonut._2} and it's price is ${glazedDonut._3}\")\n\n\n\n  println(\"\\nStep 4: How to use pattern matching on Tuples\")\n  val strawberryDonut = Tuple3(\"Strawberry Donut\", \"Very Tasty\", 2.50)\n  val plainDonut = Tuple3(\"Plain Donut\", \"Tasty\", 2)\n\n  val donutList = List(glazedDonut, strawberryDonut, plainDonut)\n  val priceOfPlainDonut = donutList.foreach { tuple => {\n    tuple match {\n      case (\"Plain Donut\", taste, price) => println(s\"Donut type = Plain Donut, price = $price\")\n      case d if d._1 == \"Glazed Donut\" => println(s\"Donut type = ${d._1}, price = ${d._3}\")\n      case _ => None\n      }\n    }\n  }\n\n\n\n  println(\"\\nStep 5: Shortcut for creating Tuples\")\n  val chocolateDonut = (\"Chocolate Donut\", \"Very Tasty\", 3.0)\n  println(s\"Chocolate donut taste level = ${chocolateDonut._2}, price = ${chocolateDonut._3}\")\n\n\n\n  println(\"\\nTip 1: A more elegant pattern matching within foreach function\")\n  donutList.foreach {\n    case (\"Plain Donut\", taste, price) => println(s\"Donut type = Plain Donut, price = $price\")\n    case d if d._1 == \"Glazed Donut\" => println(s\"Donut type = ${d._1}, price = ${d._3}\")\n    case _ => None\n  }\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_11/Option_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.two.tutorial_11\n\n/**\n  * Created by Nadim Bahadoor on 20/06/2016.\n  *\n  * Tutorial: Learn How To Use Option – Avoid Null\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-learn-use-option-avoid-null/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  *\n  */\nobject Option_Tutorial extends App {\n\n\n  println(\"Step 1: How to use Option and None - a basic example\")\n  val glazedDonutTaste: Option[String] = Some(\"Very Tasty\")\n  println(s\"Glazed Donut taste = ${glazedDonutTaste.get}\")\n\n\n\n  println(\"\\nStep 2: How to use Option and None - a basic example\")\n  val glazedDonutName: Option[String] = None\n  println(s\"Glazed Donut name = ${glazedDonutName.getOrElse(\"Glazed Donut\")}\")\n\n\n\n  println(\"\\nStep 3: How to use Pattern Matching with Option\")\n  glazedDonutName match {\n    case Some(name) => println(s\"Received donut name = $name\")\n    case None       => println(s\"No donut name was found!\")\n  }\n\n\n\n  println(\"\\nTip 1: Filter None using map function\")\n  glazedDonutTaste.map(taste => println(s\"glazedDonutTaste = $taste\"))\n  glazedDonutName.map(name => println(s\"glazedDonutName = $name\"))\n\n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_12/TypeHierarchy_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.two.tutorial_12\n\n/**\n  * Created by Nadim Bahadoor on 22/06/2016.\n  *\n  *  Tutorial: Learn The Scala Class And Type Hierarchy\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/scala-tutorial-learn-scala-class-type-hierarchy/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  */\nobject TypeHierarchy_Tutorial extends App {\n\n\n  println(\"Step 1: Declare a variable of type Any\")\n  val favoriteDonut: Any = \"Glazed Donut\"\n  println(s\"favoriteDonut of type Any = $favoriteDonut\")\n\n\n\n  println(\"\\nStep 2: Declare a variable of type AnyRef\")\n  val donutName: AnyRef = \"Glazed Donut\"\n  println(s\"donutName of type AnyRef = $donutName\")\n\n\n\n  println(\"\\nStep 3: Declare a variable of type AnyVal\")\n  val donutPrice: AnyVal = 2.50\n  println(s\"donutPrice of type AnyVal = $donutPrice\")\n  \n\n}\n"
  },
  {
    "path": "source-code/allaboutscala/src/main/scala/com/allaboutscala/chapter/two/tutorial_13/Enumeration_Tutorial.scala",
    "content": "package com.allaboutscala.chapter.two.tutorial_13\n\n/**\n  * Created by Nadim Bahadoor on 23/06/2016.\n  *\n  *  Tutorial: Learn How To Create And Use Enumerations\n  *\n  * [[http://allaboutscala.com/tutorials/chapter-2-learning-basics-scala-programming/learn-to-create-use-enumerations/ Tutorial]]\n  *\n  * Copyright 2016 Nadim Bahadoor (http://allaboutscala.com)\n  *\n  * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n  * use this file except in compliance with the License. You may obtain a copy of\n  * the License at\n  *\n  *  [http://www.apache.org/licenses/LICENSE-2.0]\n  *\n  * Unless required by applicable law or agreed to in writing, software\n  * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n  * License for the specific language governing permissions and limitations under\n  * the License.\n  *\n  */\nobject Enumeration_Tutorial extends App {\n\n\n  println(\"Step 1: How to create an enumeration\")\n  object Donut extends Enumeration {\n    type Donut = Value\n\n    val Glazed      = Value(\"Glazed\")\n    val Strawberry  = Value(\"Strawberry\")\n    val Plain       = Value(\"Plain\")\n    val Vanilla     = Value(\"Vanilla\")\n  }\n\n\n\n  println(\"\\nStep 2: How to print the String value of the enumeration\")\n  println(s\"Vanilla Donut string value = ${Donut.Vanilla}\")\n\n\n\n  println(\"\\nStep 3: How to print the id of the enumeration\")\n  println(s\"Vanilla Donut's id = ${Donut.Vanilla.id}\")\n\n\n\n  println(\"\\nStep 4: How to print all the values listed in Enumeration\")\n  println(s\"Donut types = ${Donut.values}\")\n\n\n\n  println(\"\\nStep 5: How to pattern match on enumeration values\")\n  Donut.values.foreach {\n    case d if (d == Donut.Strawberry || d == Donut.Glazed) => println(s\"Found favourite donut = $d\")\n    case _ => None\n  }\n\n\n\n  println(\"\\nStep 6: How to change the default ordering of enumeration values\")\n  object DonutTaste extends Enumeration{\n    type DonutTaste = Value\n\n    val Tasty       = Value(0, \"Tasty\")\n    val VeryTasty   = Value(1, \"Very Tasty\")\n    val Ok          = Value(-1, \"Ok\")\n  }\n\n  println(s\"Donut taste values = ${DonutTaste.values}\")\n  println(s\"Donut taste of OK id = ${DonutTaste.Ok.id}\")\n\n\n}\n"
  }
]