Introduction to Scala Constructs Welcome to Functional programming and Scala. In this course, you will learn: Key concepts of Functional Programming Scala and how to install Scala Language Constructs !aria"les, Collections, #igher order functions, and Function Literals$ %%PS Classes, %"&ects, Case Classes and Pattern 'atching$
Concepts of Functional Programming Functional Programming FP$ is a programming paradigm. It is a"out the style of how you de(elop the "loc)s of your program. It focuses not on how to compute, "ut what to compute. Functions are first class citi*ens in an FP. Let us learn a few )ey concepts that are commonly adopted in any functional programming language (i*.,
Pure functions +o side effects Immuta"ility eferential transparency #igher-order functions
Side ffects /ou must ha(e written or will "e writing lot of functions in your code. #a(e you reali*ed doing any of the following actions in a function will result in side effects0 Changing the (alue of a (aria"le 1pdating the data structure already in place Setting a field in an o"&ect 2hrowing e3ception Waiting due to an error Printing output4content to console 5ealing with files read4write$ and so on. Functions that are written without any side effects are called Pure Functions.
Immuta"ility If you cannot change something, that is immuta"le. 6n immuta"le o"&ect unchangea"le o"&ect$ is an o"&ect whose (alue or state cannot "e modified once created. Immuta"ility is not a"out restricting you to do something. It is more a"out dealing it differently. Let us see a 7uic) e3ample.
(al num"er: Int 8 9 num"er 8 ; num"er 8 ; gi(es a compilation error in Scala (al is the )eyword in Scala to define an immuta"le o"&ect
eferential 2ransparency and Purity 6 function is supposed to "e referentially transparent, if for the same input it always produces the same output. Can you thin) of an e3ample which is against this0 Let us loo) at the following pseudo code too early to write Scala code<$ function get2ime6ddedinput: Long$ 8 return System.current2ime = input$ 2he output of the a"o(e function will not "e same e(en if you call with the same argument, >at different times.> So the a"o(e function is not referentially transparent.
Why Scala Scala is "oth functional and o"&ect-oriented. a modern multi-paradigm programming language. concise, elegant, and type-safe.
Popular Functional Programming languages 2here are pure and impure functional languages. 2he list of impure languages is huge. 2hey are impure "ecause they allow a different style of writing. For e3ample, Scala is o"&ect-oriented, not &ust functional.
/ou can modify an immuta"le o"&ect once created /es4+o$ +o -/es
Scala is a pure functional programming language 2rue4False$ 2rue
False --
Which of the following are the )ey concepts of Functional Programming a. Immuta"ility ". Pure functions c. Inheritance d. eferential 2ransparency . ",d a,",d -a, " a,",c,d --wrong 9 out of ? answered.
Functional programming language cannot "e an o"&ect oriented language too 2rue4False$ --
2rue False --
Can the following pseudo function "e considered a pure function 0 function get'e2ime6ddedarg Integer$ 8 current2ime = Integer +o -/es
n(ironment for Scala Programming /ou can select one of the three ways to get started with Scala< 5ownload Scala 1se PL and Play@rounds commonly a(aila"le o(er the internet for learning. 1se SA2 Scala Auild 2ool$ or 'a(en to "uild real pro&ects. 6lso, for Scala, you can ma)e use of popular I5s such as IntelliB and clipse I5. IntelliB has good plugins for auto-completion, formatting, etc. 2his course is pro(iding em"edded PL for your hands on<
Installing Scala Learn to install Scala
5eclaring and 1sing !aria"les Let us go straight to a code snippet to understand some "asic elements of the language. ead the comments carefully in the following code. Please note: 44 is to comment a line of code and 4 4 can "e used to comment a "loc).
o"&ect 'ain e3tends 6pp D println>#ello Scala>$
44 initiali*ing an immuta"le o"&ect4(aria"le using (al (al a: Int 8 E
printlna$
44 e assignment to a (al00 uncomment and see the compilation error. 44 a 8 9
44 initiali*ing a muta"le (aria"le using (ar 44 a legal e3pression e(en though we ha(ent e3plicitly stated the data type of G"G. (ar " 8 9 44 Scala compiler can infer the data type as Int. " 8 ; 44 we can mutate the (alue of G"G since its declared as G(arG H #ere o"&ect 'ain inherits the main method of 6pp. 6pp is called as trait, which is e7ui(alent to interface in Ba(a.
5eclaring and 1sing !aria"les Contd... 2o summari*e, 5eclaring a (aria"le with (ar, ma)es it muta"le 5eclaring a (aria"le with (al ma)es it immuta"le eassignment of an immuta"le (aria"le is not possi"le 5ata type declaration happens after the (aria"le name and a colon :
5ata type declaration is not mandatory In the a"sence of e3plicit data type declaration, Scala can infer the (aria"le type "ased on the (alue assigned line of code or "loc) of code can "e commented using 44 or 4 4
#igher %rder Functions Bust li)e we pass (aria"les or o"&ects as arguments to functions, we can pass around function itself as an argument to another function in Scala. (en the return type of a function can "e another function< 2hese type of functions are called as #igher %rder Functions.
Function 5efinition 3plained Scala synta3 is fle3i"le, and there are different ways you can write a function from a synta3 point of (iew. Let us loo) at a simple function definition first. def add%nearg: Int$: Int 8 D arg = E H def is the )eyword to define a method or function. add%ne is a function that ta)es an integer as argument and returns another integer as result. Scala notation to e3press it: Int 8 Int /ou can say Int gi(es Int <$
3ercise 9 o"&ect 'ain e3tends 6pp D 44 def add$ 44 complete the function definition (al a 8 ? (al " 8 E? 44 (al result 8 add...$
printlnresult$
H
Create a #igher %rder function Let us consider the following code snippet, my#igher%rderFunction function that ta)es two parameters.
First parameter or argument is a function i.e. a function itself as an argument$. 2he function which is passed, when called, should "e of type Int 8 Int. /ou could relate this to a function definition in the pre(ious section. Second parameter is a (alue, a regular )ind of parameter that we see. def my#igher%rderFunctionargFn: Int 8 Int, arg!al: Int$: Int 8 D println>Inside my#igher%rderFunction >$ printlns>Jn 6pplying the arg function to arg!al 8 arg!al>$ argFnarg!al$ 44 compute the argFn and return the result H 6nother ta)eaway: Loo) at the second print statement in the snippet and understand how to su"stitute a (aria"le (alue in a string.
Calling a #igher %rder Function
(al my+um"er 8 E (al result 8 my#igher%rderFunctionadd%ne, my+um"er$ printlnresult$ 2he output of the a"o(e code would "e EE. 5o you )now how that is done0
Language Constructs and Functions Muestion Copy the following snippet to the console and see the result.
o"&ect 'ain e3tends 6pp D def add%nearg: Int$: Int 8 D arg = E H def my#igher%rderFunctionargFn: Int 8 Int, arg!al: Int$: Int 8 D argFnarg!al$ 44 compute the argFn and return the result H (al myInput 8 E printlnmy#igher%rderFunctionadd%ne, myInput$$ H
5ata 2ypes in Scala Function Literals In Scala, functions can "e e3pressed in function literal
For e3ample: 3: Int$ 8 3 = E is a function literal 2hose functions can "e represented "y o"&ects, which are called function (alues. 2he a"o(e function can "e read as, a function which ta)es an integer argument and returns an integer result. /ou can assign it to an o"&ect also as (al f 8 3: Int$ 8 3 = E
1sing Function Literal #ere is an e3ample snippet to show to use function literals or function (alues:
def my#igher%rderFunctionargFn: Int 8 Int, arg!al: Int$: Int 8 D argFnarg!al$ 44 compute the argFn and return the result H If the literal is not assigned to an o"&ect, it can "e used as (al result 8 my#igher%rderFunctiona: Int$ 8 D a = E H, E9$. If the same is assigned to an o"&ect f, it can "e used as (al result 8 my#igher%rderFunctionf, E9$. Aoth will gi(e the same result. Function literals are also )nown as anonymous functions.
What would "e the output of following snippet (al s 8 ListE,9,;,N$ (al t 8 List?,O,,Q$ (al n 8 s == t printlnn$ +one of the options ListE, 9, ;, N, ?, O, , Q$ -List?, O, , Q, E, 9, ;, N$ ListE, Q$ E out of ? answered.
Is this a (alid e3pression (al f: Int 8 3: Int$ 8 3 = E +o --
/es
For the gi(en statement, (al s 8 ListE,9,;$ What would "e the type of s0 6rrayRInt ListRInt -+one of the options Integer
What is the default class List is imported from 0 scala.collection.muta"le scala.collection.immuta"le -+one of the options scala.lists.immuta"le ; out of ? answered.
preferred 7ualifier for defining a (aria"le in Scala. !ar !al --
Scala Collections Collections let you organi*e large num"ers of o"&ects. Scala has a rich collection li"rary In simple cases, you can throw a few o"&ects into a set or a list and not thin) much a"out it. For tric)ier cases, Scala pro(ides a general li"rary with se(eral collection types, such as se7uences, sets and maps. ach collection type comes in two (ariantsTmuta"le and immuta"le. 'ost )inds of collections ha(e se(eral different implementations that ha(e different tradeoffs of speed, space, and the re7uirements on their input data.
Lists Let us get started with List, one of the most used collections in Scala. List, as the name goes, is similar to arrays. It is a collection of elements of the same type. #ere is an e3ample to create an integer list: (al intList: ListRInt 8 ListE,9,;$. 6s Scala is a language with lot of syntactic sugar and "uilt-in type inference features, programmers can write the a"o(e e3pression as (al intList 8 ListE,9,;$ 44 this is (alid too.
'ap Collections in Scala has a lot of "uilt-in functions, and many of them are of type higher order functions. Let us see an e3ample.
44 function to con(ert an integer to a string def
co(ert2oStringarg: Int$: String 8
arg.toString
+ow, the following snippet would con(ert a list Integer (alues to a list of String, using map function.
(al newList: ListRString 8 intList.mapco(ert2oString$ 44 con(ert2oString is a function which is passed onto map function in list. 2he function map in List type is a higher order function. It accepts a function that operates on one element of a List at a time. 2he argument function maps one element of list to another type say, 1. i.e once you apply the map function on a list of type ListR2, the result you get "ac) is a ListR1. +ote: 1 can "e same as 2 as well
Muestion Copy the following snippet to the console and complete the functions to add E to all elements in the list. ie if the input is ListE,9,;,N$ output e3pected is List9,;,N,?$
o"&ect 'ain e3tends 6pp D
(al input 8 ListE,9,;,N$
44 write a function to add E to an integer (alue
44use map function on input and call the a"o(e function to get the result
Collection #ierarchy Scala collections orderly differentiate immuta"le and muta"le collections. 6 muta"le collection can "e e3tended or updated in place. i.e. user can include, change or e3clude elements of a collection as a side effect. Ay contrast, immuta"le collections, ne(er change. Still, a user has operations that simulate updates, remo(als, or additions. #owe(er, these operations will return a new collection in each case and allow the old collection unchanged, as well.
Collection Classes 2he entire lot of collection classes are a(aila"le in the scala.collection pac)age or one of the su"-pac)ages of scala.collection - generic, immuta"le, and muta"le. 'ost collection classes needed "y client code e3ist in three (ariants, which are located in pac)ages scala.collection, scala.collection.immuta"le, and scala.collection.muta"le, respecti(ely. ach (ariant features distinct characteristics on muta"ility. +ote: Ay default, Scala always ta)es collection from the immuta"le hierarchy. For instance, If you &ust write Set without any prefi3, or without ha(ing imported Set from somewhere, you will get an immuta"le set. If you write Itera"le, you will get an immuta"le itera"le collection, "ecause these are the default "indings imported from the Scala pac)age. 2o ha(e the muta"le default (ersions, you ha(e to write e3plicitly collection.muta"le.Set, or collection.muta"le.Itera"le
Filtering
2here are plenty of "uilt-in functions pro(ided in Scala for all collections. We will loo) at a few of the commonly used ones. #ere is an e3ample of filter and Usome more syntactic sugars in Scala. It is fun. ead the commented part carefully. o"&ect 'ain e3tends 6pp D (al lst 8 ListE, 9, ;, N, ?, O, , Q, V, E$ 44 e3ample for filtering all elements greater than ? (al g? 8 lst.filteri 8 i ?$ printlng?$ H 2he a"o(e statement also shows usage of an anonymous function. ie i 8 i ? is actually of type Int 8 Aoolean. type of i is not e3plicitly gi(en as Scala understands that it is an Integer. Writing it as i: Int 8 i ? is also correct. 6nother simplification in terms of Syntactic sugar is to write the e3pression as (al g? 8 lst.filterU ?$. U underscore$ will "e replaced "y the elements of the list "y Scala compiler for you.
foreach foreach is an e3ample of a method that can ha(e side effects. foreach does not return anything. It can "e used for writing the output to dis), data"ase, printing, etc. (al intList 8 ListE,9,;,N,?$ intList.foreachprintln$ 44 foreach is of return type G1nitG 6"o(e snippet will print the result to stdout. 1nit is the return type to mean there is nothing returned. #ence the methods of return type 1nit can ha(e side effects, i.e., they are not pure functions. 5oes it ma)e sense with the functional programming concepts we learned0
%ther Important Functions in Collections efer the scala li"rary 5o some e3ercises on your own. We will co(er few of the comple3 ones in the upcoming courses.
What is flat'ap0 We ha(e already tried some e3amples with map. flat'ap is (ery similar to map.
#owe(er, there are some differences concerning the functions that are passed onto them. Aoth map and flat'ap can "e applied on many other data structures and where they are supported. Let us use List as an e3ample here to understand a"out flat'ap easily. 2o ma)e it clear, map accepts a function that returns 1 for a gi(en 2. #ere, 2 8 1, hope you remem"er the pre(ious e3ample a"out Int 8 Int. 2 and 1 are generic types here. flat'ap accepts a function that returns a ListR1 for e(ery 2. ie the function passed onto it should "e of type 2 8 ListR1. 2he results are finally flattened to create a single ListR1. It might "e loo)ing slightly complicated. Some e3amples would ma)e it clear.
3ample for flat'ap Following snippet gi(es an e3ample for flat'ap. o"&ect 'ain e3tends 6pp D (al intList 8 ListE,9,;,N,?$ def return2woarg: Int$: ListRInt 8 Listarg, arg$ (al newList 8 intList.flat'apreturn2wo$ printlnnewList$ H output of the a"o(e snippet would "e ListE,E,9,9,;,;,N,N,?,?$ #ope that is clear now<
%"&ects Scala is a pure o"&ect oriented language and it e3tends the use of classes, o"&ects, interfaces, etc. to programmers. While wor)ing on "uilding applications using Scala, you can decompose your program into classes, o"&ects, etc. to deal with comple3ities. In other words, a class should "e responsi"le for a reasona"le amount of functionality. In the process of designing your classes, you can also design interfaces to those classes that a"stract away the details of their implementation.
%"&ects and !aria"les When writing the code of a Scala program, you create and interact with o"&ects. 2o interact with a particular o"&ect, you can use a (aria"le that refers to the o"&ect. /ou can define a (aria"le with either a (al or (ar, and assign an o"&ect to it with 8.
For e3ample, When you write (al i 8 E, you create an Int o"&ect with the (alue E and assign it to a (aria"le. In this case, a (al named i. Similarly, when you write (ar s 8 >#appy>, you create a String o"&ect with the (alue >#appy> and assign it to a (aria"le, a (ar named as s.
Singleton %"&ects %ne way in which Scala is more o"&ect-oriented than Ba(a is that classes in Scala cannot ha(e static mem"ers. Instead, Scala has singleton o"&ects. 6 singleton o"&ect definition loo)s li)e a class definition, e3cept instead of the )eyword class you use the )eyword o"&ect. #eres an e3ample: 5ont worry a"out the logic in the following snippet. #owe(er you may e3plore what is for comprehension in Scala.
o"&ect simple%"&ect3ample
D
(al default!alue 8 9 def doSomethingarg: Int$ 8 D arg 9 ; H H /ou can use the functions or mem"ers as o"&ect+ame.mem"er. for e3: simple%"&ect3ample.doSomethingE$ We ha(e already used singleton o"&ects in our pre(ious sections, in (arious places. 5o you remem"er0
Classes 6 class is considered as a "lueprint for o"&ects. %nce you define a class, you can create o"&ects of it using the )eyword new. For e3ample, gi(en the class definition: class #ome D 44 class definition goes here 44 define your mem"ers here "oth (aria"les and functions$ H /ou can create #ome o"&ects also )nown as instances of class #ome$ with: new #ome 6 user can assign the o"&ect to a (aria"le, for later reference and usage. (al hE 8 new #ome
you can construct many o"&ects from one class: (al h9 8 new #ome (al h; 8 new #ome /ou now ha(e three #ome o"&ects.
Case Class case classes are similar to classes. /ou need to a put a )eyword case in front of class. Is that all 0 +o. /ou can "uild o"&ects of them without using new )eyword. #ow do I create a case class.
case class Frescospecialisation: String, course+ame: String$ +ow creating an o"&ect of type Calculator is easy enough as (al o"& 8 Fresco>modern data platform>, >functional programming in Scala>$ 2here is no new )eyword used, no setter methods used. case classes can ha(e methods &ust li)e normal classes
Pattern 'atching Pattern matching is (ery similar to switch case structures that you would ha(e seen other programming languages. #owe(er, Pattern 'atching in Scala has lot more to do< Let us start with a simple e3ample. 'atching on !alues (al times 8 E times match D case E 8 >one> case 9 8 >two> 44 U matches e(erything else case U 8 >some other num"er> H /ou can also use the concept called guards along with pattern matching. 6n e3ample is here. 44 +ote the if conditions gi(en in case times match D case i if i 88 E 8 >one> case i if i 88 9 8 >two>
case U 8 >some other num"er> H
Pattern 'atching on types We ha(e seen one case of pattern matching, that was matching on (alues. +ow let us loo) at an e3ample of matching on types, sounds interesting0 /ou can use a match to handle (alues of different types differently. 44 6ny is the super type of all "uilt-in types in Scala. In this e3ample, argument o is matched against a type, whether it is 5ou"le or Int "efore doing an operation. def "iggero: 6ny$: 6ny 8 D o match D case i: Int if i X 8 i - E case i: Int 8 i = E case d: 5ou"le if d X . 8 d - .E case d: 5ou"le 8 d = .E case te3t: String 8 te3t = >s> H H
Pattern matching on case classes case classes are designed to "e used with pattern matching.
a"stract class +otification case class mail sender: String, title: String, "ody: String$ e3tends +otification
case class S'S caller: String, message: String$ e3tends +otification
case class !oiceecording
contact+ame: String, lin): String$ e3tends +otification +otification is an a"stract super class which has three concrete +otification types implemented with case classes mail, S'S, and !oiceecording.
Pattern 'atching on Case Classes Contd... +ow we can do pattern matching on these case classes:
def show+otificationnotification: +otification$: String 8 D
notification match D case mailemail, title, U$ 8 s>/ou got an email from email with title: title>
case S'Snum"er, message$ 8 s>/ou got an S'S from num"er< 'essage: message>
case !oiceecordingname, lin)$ 8 s>you recei(ed a !oice ecording from name< Clic) the lin) to hear it: lin)> H H
(al someSms 8 S'S>E9;N?>, >6re you there0>$
(al some!oiceecording 8 !oiceecording>2om>, >(oicerecording.org4id4E9;>$
44 prints /ou got an S'S from E9;N?< 'essage: 6re you there0
printlnshow+otificationsomeSms$$
44 you recei(ed a !oice ecording from 2om< Clic) the lin) to hear it: (oicerecording.org4id4E9;
printlnshow+otificationsome!oiceecording$$
2raits 2raits are applied to share fields and interfaces "etween classes. 2hese are same as Ba(a Qs interfaces. %"&ects and classes can e3tend traits. #owe(er, traits cannot "e instantiated and hence ha(e no parameters. 5efining a trait 6 minimal trait is simply the )eyword trait and an identifier: e3: trait #airColor e3tends is the )eyword to inherit from a trait.
2raits 3ample Let us loo) at an e3ample for trait.
trait AaseSoundPlayer D
def play def close def pause def stop def resume H
If a class implements one trait it will use the e3tends )eyword:
class 'p;SoundPlayer e3tends AaseSoundPlayer D
def play
DH
def close
DH
def pause
DH
def stop
DH
def resume DH H
%ne trait can e3tend another trait: If a class e3tends a trait "ut does not implement the methods defined in that trait, it must "e declared a"stract:
Implementing 'ultiple 2raits If a class implements multiple traits, it will e3tends the first trait or a class, or a"stract class$, and then use with for other traits: #ere is an e3ample
a"stract class 6nimal D def spea) H
trait Wagging2ail D def start2ail def stop2ail H
trait FourLegged6nimal D def wal) def run H
class 5og e3tends 6nimal with Wagging2ail with FourLegged6nimal D 44 implementation code here ... H
Scala Constructs Course Summary In this course, you ha(e learnt Scala as functional program !arious programming constructs 1sage of higher order functions 1nderstand Scala collections and "uilt-in functions Scala is an o"&ect oriented program
Singleton is created in Scala using )eyword "oth o"&ect and class class o"&ect -trait
toString is a default method a(aila"le for new class definition that can "e o(erride 2rue -False
Which of the following feature in Ba(a resem"les trait in Scala a"stract class interface -generics pac)age
9 out of 9? answered.
Scala supports only single inheritance 2rue -False ; out of 9? answered.
Consider the following code snippet def prnt 8 Dprint>scala>$Y EH def funa:Int,": 8 Int$ 8 printa$ What will "e the output for function call funprnt,?$0 scalaE scala? scalaE? -?scalaE
Consider the following code snippet D(al 3 8 38?H the output of the a"o(e e3pression would "e ? none of the options error -
Which of the following cannot ha(e a constructor all the options o"&ect a"stract class
trait --
Scala has immuta"le collections False 2rue --
What would "e the type inferred "y Scala compiler for (aria"le salary. (al salary 8 ;. Int 5ou"le Float -Long
Which of the following type allows only single instance to e3ist in glo"al scope Int class def o"&ect --
Singleton o"&ect in Scala can "e made e3ecuta"le "y e3tending 6pp "y defining a class "y e3tending 6pp or with the main function -with the main function
In functional programming language functions can "e passed as an argument --
can only "e passed as call "y (alue cannot "e returned as a result
Which all framewor)s are de(eloped using Scala Spar) -'esos 5oc)er
Functions can "e declared anywhere in Scala False 2rue --
What would "e the output of the following code snippet (al s 8 List E, EE, E9$ (al result 8 s.flat'api 8 Listi-E, i, i =E$$ printlnresult$ ListV, E, E, EE, E, E9, E9, EE, E;$ ListListV,E,EE$, ListE,EE,E9$, ListEE,E9,E;$$ -+one of the options ListV, E, EE, E, EE, E9, EE, E9, E;$
Functions are first class o"&ects in function programming 2rue -False
%"&ect )eyword is used to define a singleton class in Scala False 2rue --
@i(en the following snippet def chec)%ddn:Int$: Aoolean 8 if n Z 9 <8 $ true else false def chec)(enn:Int$: Aoolean 8 if n Z 9 88 $ true else false (al num"ers: ListRInt 8 ListE,N,;,O,Q,E,NV,?,;;,O$ What are the right e3pression to filter all e(en num"ers 6ll the options mentioned (al e(enList 8 num"ers.filter< chec)%ddU$$ (al e(enList 8 num"ers.filterchec)(enU$$ (al e(enList 8 num"ers.filtern 8 chec)(enn$$ --
Scala compiler will compile the following e3pression successfully (al s: Int 8 ?.? False 2rue --
What would "e the output of following code snippet. (al l 8 ListE, E, E, E, 9, 9, 9, 9, 9, ;, ;, ?, ?, Q$ printlnl.ta)e;$$ +one of the options ListE$ List?,?,Q$ ListE,E,E$ --
Scala"ility is an important trait of a functional programming language What is the result of the "elow snippet 0 (al i 8 E. i match D case t: Int 8 println>It is integer>$ case t: Float 8 println>It is Float>$ case U 8 println>no match found>$ H It is integer
It is Float -no match found 0 2rue False
Which of the following pro(ides way to multiple inheritances in Scala trait -o"&ect a"stract class interface
What would "e the output of this code (al n 8 ListE,9,;,N,?$ printlnn.mapU Z 9$$ List, E, , E, $ Compilation error +one of the options -ListE, , E, , E$
Following "uild tools can "e used to "uild Scala pro&ects @radle 'a(en SA2 6ll the options mentioned --
@i(en the following snippet, what would "e the output (al l 8 ListE, E, E, E, 9, 9, 9, 9, 9, ;, ;, ?, ?, Q$ printlnl.dropE$ List;, ;, 9, 9, 9, 9, E, E, E, E$ List;, ?, ?, Q$ -+one of the options ListQ, ?, ?, ;, ;, 9, 9, 9, 9, E, E, E, E$ E out of 9? answered.
Case classes can not contain mem"er functions False 2rue V out of 9? answered.
Scala classes can contain static mem"ers 2rue False --
'athematical functions are "est implemented in0 logical programming language functional programming language -interacti(e programming language o"&ect oriented programming language out of 9? answered.
Which of the following is a pure functional programming languages #as)ell -Scala Clo&ure Ba(a