Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Compile and Execute Scala Online

object HelloWorld {
   def main(args: Array[String]) {
      val Salaries = List(1000,2000,3000)
      val out = Salaries.map(x => x + 200)
      for ( a <- out){
          println("my value is " + a)
      }
   }
}

Compile and Execute Scala Online

object HelloWorld {
   def main(args: Array[String]) {
      println("Hello, world!")
   }
}

Compile and Execute Scala Online

object HelloWorld {
   def main(args: Array[String]) {
      val l = List(1,2,3,4)
      val x = l.:+(6)
      val y = List(9) :: x
      println(y.getClass())
      
       val mainList = List(3, 2, 1)
 val with4 =    4 :: mainList  // re-uses mainList, costs one :: instance
 val with42 =   42 :: mainList // also re-uses mainList, cost one :: instance
 val shorter =  mainList.head  // costs nothing as it uses the same 2::1::Nil instances as mainList
 println(shorter)

 println("---------------")
 
    val a = List(1,2,3,4)
    val b = (5 /: a)(_*_)
    val c = (a :\ 5)(_*_)
    println(b + " " + c)
    
 println("-------------- copy to array example")
    
    
   }
}

Runi

object HelloWorld {
   def main(args: Array[String]) {
      println("Hello, world!")
      for (arg<-args)
         println(arg)
   }
}

Compile and Execute Scala Online

class checkEven(){
    def isEven(n: Int) = {
        if(n%2 == 0)
        println("Even")
        else 
        println("Odd")
    }
}

object IsEvenClass{
    
    def main(args: Array[String]){
        val e1 = new checkEven()
        println("hello world")
        e1.isEven(3)
        
       
    }
}

Hello

object HelloWorld {
   def main(args: Array[String]) {
      println("Hello, world!")
   }
}

Point

object HelloWorld {
   def main(args: Array[String]) {
      println("Hello, world!")
   }
}

MyProject

object Hell {
   def main(args: Array[String]) {
      println("Hello, world!")
   }
}

Bobolo

object HelloWorld   {

scala>20
}

member

//Eric Staffieri
//Scala - Member

import scala.annotation.tailrec
object HelloWorld {
   def main(args: Array[String]) {
      val list = List(1,2,5,4)
      println(member(4, list))
      println(member(6, list))
   }
    def member(x: Int, list: List[Int]): Boolean = list match {
        case h :: t => if (x == h) true else member(x, t)
        case Nil => false
    }
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.