scala intro

in scala – we use class parameters and these are used in the constructor , define these with val and it becomes field of the class , all fields and methods in scala are public by default

class circle( val rad:Double) {
     | def getArea:Double = 3.14 *rad *rad 
     | }
defined class circle

// in this case the field rad is class parameter and a field in the class 

you can use the override keyword to over ride the implementation of an existing method

val c = new circle(5)
c: circle = circle@15dd0233

val c1 = new circle(6)
c1: circle = circle@80c7b36

scala> val c2 = new circle(7)
c2: circle = circle@59da892a

scala> 

scala> val circlelist = List(c,c1,c2)
circlelist: List[circle] = List(circle@15dd0233, circle@80c7b36, circle@59da892a)

scala> circlelist.map(_.getArea)
res55: List[Double] = List(78.5, 113.03999999999999, 153.86)



Case class  – comes with a default apply method , which builds the class for us  , so we can avoid the new method. Case classes are essentially immutable classes so you cannot extend another case class. Since it comes with a default apply method , you dont use the new word to instantiate an object . Case classes can be copied because Scala gives us a built in copy method.

A common question on #scala is, what’s the difference between a parameter of type A and one of type => A? The short answer is:

A parameter of type A acts like a val (its body is evaluated once, when bound) and one of type => A acts like a def (its body is evaluated whenever it is used).

From <https://tpolecat.github.io/2014/06/26/call-by-name.html>

So what is thunk – it’s a function that takes no arguments , you can call the function and because its lazily evaluated , its not run until its really needed….this is one way to delay the execution of something

Akka  – actor based concurrent programming , javas implementation of threading uses shared memory and locking .  This is difficult . Actors are concurrency abstractions that can be implemented on top of threads . They communicate by sending messages to each other. An actor can perform two basic operations message send and receive