Before going into Partially applied Functions, let me introduces 2 terms- Function Literal- This exists in the source code- Something similar to Class definition. So we have [scala gutter=”false”] (x:Int,y:Int) => x+y [/scala] Function value- When this function literal is… Read More ›
If Statements: Lets consider a first entry example of If statments, without using much of Scala’s features. This is a pretty simple and straight forward examples. Now lets add some Scala flavor in the If-Statement. In Scala If-Statements are expressions,… Read More ›
When I was coding in Java I used to build Classes just to return multpile values and also sometimes used pass by reference (by means of using Objects). I really missed a permanent solution 😦 Scala has a solution for this- It supports something called “Tuples” which is created with the literal syntax of a comma-separated list of the items inside parentheses like (x1,x2,x3 …). The items in the parantheses may not be related to each other in terms of the type, which means that we can have String’s, Int’s and so on. These literal “groupings” are instantiated as scala.TupleN instances, where the N is the number of items in the tuple. The Scala API defines separate TupleN classes for N between 1 and 22, inclusive. Tuples can be assigned to variables, passed as values or return them from the methods.