scala get nth element of list code example Example: how to get the nth element in a list in scala val x = List(1,2,3,4,5) println(x(3)) // output: 4