- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
What's the type of a singleton object and how to use it?
Wed, 2009-09-09, 07:10
In a particular case, how can I refer to the type of None:
trait Container[X]
def onlyForNone(x:Container[None]) = //... doesn't compile since None
is no type
def onlyForNone(x:Container[None.type]) = //... compiles, but can't
be used since 'Container[object None]' is not the same as
'Container[None.this]'
Would that work, one could use the Option hierarchy for both values
and type-level Booleans as I proposed here:
I had to introduce my own version of the Option hierarchy with an
additional 'trait None' to have a type which to match over. Is there
another possibility?