How to get the last element of a list in Scala

1 Answer

0 votes
object O {
    def main(args: Array[String]): Unit = {
        val lst = List("scala", "c", "c++", "java", "php") 
  
        println(lst.last) 
    }
}
    
     
     
     
/*
run:
     
php
 
*/

 



answered Sep 8, 2020 by avibootz
...