Hello I have the follwong :
trait CarObject{
val name: String
}
def takeCarObject(obj:CarObject)
How could I prepare a trait object ,CarObject, and pass it to the method ?
I have tried :
private def createCarObject(str: String) = new CarObject { val name =
str}
but the result is n’t a CarObject !
This does work:
Notice: If you don’t explicitly set a return value to the method, the return value
java.lang.Object with XXXis inferred, where in this case XXX isCarObject.