I am going through some scala code. I have come across a sign "<:". What does it mean?
Here is the following code.
abstract class HierarchicalDatabaseObject[TParent <: DatabaseObject](databaseId: String) extends DatabaseObject(databaseId)
I am going through some scala code. I have come across a sign "<:". What does it mean?
Here is the following code.
abstract class HierarchicalDatabaseObject[TParent <: DatabaseObject](databaseId: String) extends DatabaseObject(databaseId)
It's a upper bounded wildcard. If you're familiar with Java it's like ? extends DatabaseObject
.
It means, that the Type you put in has to be a Subtype of DatabaseObject
.
This basically guarantees, that your generic Type has atleast all the same methods and properties that DatabaseObject
has, making it much more useful, than when unbound.
You can check out more examples in the documentation.