What does this sign "<:" mean in scala?

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 ? 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.

链接地址: http://www.djcxy.com/p/72852.html

上一篇: 斯卡拉什么是<:<运营商

下一篇: 这个符号“<:”在scala中意味着什么?