trait Link[This] { var next:This = null }
gives "type mismatch": found: Zero (zero): this "
So, suppose I need to tell the type of check that it will be a type that can be set to null. How to do it?
(If there is a site that I must read first before asking such questions, please call me on it. I am currently partially reviewing the preprint of the 2nd Scala Programming Editor)
This Null - , Null . ( Any, AnyRef AnyVal - , !)
This
Null
Any
AnyRef
AnyVal
trait Link[This >: Null] { var next:This = null }
Null, Option[This] None - , , , , , .
Option[This]
None
trait Link[This] { var next:Option[This] = None }
trait Link { var next:This = null }
. , ?
, . , .
trait Link[This <: AnyRef] { // Without the type bound, it Any var next: This = null }
, :
trait Link[This <: AnyRef] { var next: This = null.asInstanceOf[This] }
, .
Source: https://habr.com/ru/post/1780051/More articles:In C #, how can I access a file archive in a domain from outside the domain? - c #Selling Android apps in mainland China? - androidDICOM Basics for Volumetric Data - medicalКак добавить текст в изображения с помощью CMYK ColorSpace в .NET 4 - c#How to convert CMYK to RGB programmatically in indesign - javaConcurrent requests in Solr - jettyC # Cache Management in Code or IIS 6 - c #Google Apps Marketplace - SSO for Google App Engine Java - google-app-engineИспользование объектов функции в параллельном_for - c++Will FinishLaunchingWithOptions be executed after installing the new version? - iphoneAll Articles