Advertisement
jmvanel

make use of inherited function in inner class

Mar 16th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   /** I want to make use of inherited function print() in inner class */
  2. class PassImplToInnerClass extends OutputterImpl {
  3.   class Inner extends Outputter {
  4.     // ??? is there a less tedious way to avoid this ERROR:
  5.     // class Inner needs to be abstract, since method print in trait Outputter of type ()Unit is not defined
  6.     def print() = PassImplToInnerClass.this.print
  7.   }
  8. }
  9.  
  10. trait Outputter { def print() }
  11.  
  12. class OutputterImpl extends Outputter {
  13.   def print() = println("bla")
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement