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

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -