Scala Abstract Type Member -


i noticed can instantiate scala trait abstract type member. code below compiles. t.b?

trait {     type b }  val t = new {} 

the type t.b.

trait {   type b   def f(b: b) }  val t = new { def f(b: b) = {} }  t.f(0) 

has error

error: type mismatch; found   : int(0) required: t.b 

types don't have "overriden" methods.

this type own thing. it's not useful, that's is.

like other types, subtype of any , supertype of nothing.

seq[t.b](): seq[any] seq[nothing](): seq[t.b] 

and that's can said it.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -