Say I have a method like this:
def getClassFromIterable(iterable: Iterable[Any]): Class[_] = {
iterable.head.getClass
}
This will get the class of the top of the list, but will fail if the list is empty.
How can I get the class of a passed list that has zero or more elements?
Aucun commentaire:
Enregistrer un commentaire