generics - Type definitions in Scala -


i have scala pre-examination question cannot through. help.

does expression on right conforms declared type, , why?

(a) val x1: b => d = (b: a) => new d

(b) val x2: => c => d = (a: a) => (b: d) => new c

(c) val x3: (d => b) => = (db: d => a) => new b

the class hierarchy:

class a

class b extends a

class c

class d extends c

you don't need this. paste code repl.

scala> class defined class  scala> class b extends defined class b  scala> class c defined class c  scala> class d extends c defined class d  scala> val x1: b => d = (b: a) => new d x1: b => d = <function1>  scala> val x2: => c => d = (a: a) => (b: d) => new c <console>:10: error: type mismatch;  found   : c  required: d        val x2: => c => d = (a: a) => (b: d) => new c                                                  ^  scala> val x3: (d => b) => = (db: d => a) => new b x3: (d => b) => = <function1> 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -