Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

11.
Scala Collection HierarchyAll Collection classes are in scala.collection or one of its sub-packages mutable, immutable and genericRoot collections in the package scala.collection define thesame interface as immutable collections and mutablecollections add some modification operations to make itmutableThe generic package contains building block for implementingCollections.

19.
Trait IterableThis is the next Trait in Collection hierarchy. All methods in this traitare defined in terms of an abstract method iterator, which returnscollection results one by one.The foreach method from trait Traversable is implemented inIterable in terms of iteratordef foreach[U](f: Elem => U): Unit = { val it = iterator while (it.hasNext) f(it.next())}

20.
An Example ..Task: Phone keys has mnemonics attached to themval mnemonics = Map( 2 -> "ABC", 3 -> "DEF", 4 -> "GHI", 5 -> "JKL", 6 -> "MNO", 7 -> "PQRS", 8 -> "TUV", 9 -> "WXYZ")Assume that you are given a dictionary dict as a list of words. Design aclass Coder with a method translate such that new Coder(dict).translate(phoneNumber)Produces all phrases of words which can serve as mnemonics for thephone numberExample The phone number “7225276257” should have a mnemonic Scala rocksas one element of the list of solution phrases

22.
Everything is a libraryCollections feel they are language constructsLanguage does not contain any collection relatedconstructs - no collection types - no collection literals - no collection operatorsEverything is in libraryThey are extensible