The list.tail
function in Scala returns the reference of all the elements in the list except the first element.
Figure 1 shows a visual representation of the list.tail
function.
list_name.tail
// where the list_name is the name of the list
This function does not require any parameters.
The list.tail
function returns the reference of all the elements in the list except the first element.
error
.The following code shows how to use the list.tail
function in Scala.
object Main extends App {var list = List(1,3,4,2,0)//list = 1->3->4->2->0println("Following are the elements in List before using list.tail: " + list);println("The elements on the tail of list: "+list.tail);println("Following are the elements in list after using list.tail: " + list);}