Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Scala, can internal methods be overwritten in subclasses?

Tags:

scala

For example in the following

class Base {

  def test() {
    def internal() {
      println("base internal")
    }
  }
}

Is it possible for internal to be overwritten in a subclass?

like image 200
deltanovember Avatar asked Aug 27 '11 00:08

deltanovember


2 Answers

No. Internal methods are effectively private.

like image 125
Daniel C. Sobral Avatar answered Nov 14 '22 23:11

Daniel C. Sobral


To complete the answer of Daniel: if you want to be able to override the internal method, you should declare it as protected directly below the Base class.

In fact, internal method can be seen as a block of the method itself.

like image 35
Nicolas Avatar answered Nov 14 '22 22:11

Nicolas