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 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")
    
    
   }
}

Advertisements
Loading...

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