Thursday, 17 August 2017

Introduction of Scala




Scala is a multi-purpose programming language provide support for functional programming and strong static type system.

Code snippet:-
package com.test.one
import scala.io.Source
object Test {
  def main(args: Array[String]) {
    //print simple string.
    println("hello")
  }
 }

package com.test.one
import scala.io.Source
object Test {
  def main(args: Array[String]) {
     //variable declaration...
     val myVal : String = "Test"
       print(", "+myVal)
   }
}

package com.test.one
import scala.io.Source
object Test {
  def main(args: Array[String]) {
    matchTest("two")
  }
  def matchTest(x: Any) {
    println(x);
  }
}

package com.test.one
import scala.io.Source
object Test {
  def main(args: Array[String]) {
     var myList1 = Array(8.9, 7.9, 0.4, 1.5)
     // list iteration..
     for(x <- myList1) {
       print(", "+x)
     }
   }
}


1 comment: