I have started learning scala and I wonder is there a way I could get elements in the List from the right side
For example
val myList = List(1, 2, 3, 4, 5)
if I writemyList(-1) I would get 5.
Is there any simple way to get it done or I’ll have to write my own function?
? Remember that this operation has O(n) complexity for
List. Also you can simply reverse the list and use normal indices: