I have just started learning scala and I am pretty confused with Generics:
Question 1:
def getRemainingItem[X](list : List[X], fun : (X) => Boolean) : List[X] = {
list.filterNot(fun)
}
What is X here looks like E of Java(This code works fine)
Question 2:
def getRemainingItem(list : List[Any], fun : (Any) => Boolean) : List[Any] = {
list.filterNot(fun)
}
Why is Any not working. I am thinking Any can accept any type (this isn't compiling)
Question 3:
def getRemainingItem(list : List[_], fun : (_) => Boolean) : List[_] = {
list.filterNot(fun)
}
Again this is not working and what is the difference between "_" and "Any"