I want to write a function that returns every item in a List that is not the first or the last item (a via point). The function gets a generic List<*&g
List
List<*&g
To improve @hotkey's answer here's my solution:
val waypointList = list.filterIsInstance().takeIf { it.size == list.size }
This gives you the List if all the items can be casted, null otherwise.