scala - Create a child class's instance in parent class's method -


abstract class parent {    def filter(p: parent => boolean): parent = filteracc(p, new child) }  class child extends parent {   // ... } 

i working on scala tutorial , wondering how following can possible.

there 2 classes parent , child. parent class creates instance of child in method filter.

how can parent class refer child class inherits parent class?

that no contradiction. if parent , child defined within same compilation unit, parent can refer sub-class, both symbols/types known each other.


Comments

Popular posts from this blog

Capture and play voice with Asterisk ARI -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -