Inner classes: Difference between revisions

→‎{{header|Wren}}: Added some remarks to preamble about accessing outer class methods.
m (Fixed typos.)
(→‎{{header|Wren}}: Added some remarks to preamble about accessing outer class methods.)
Line 206:
However, it is possible to declare a class within either a method or function and we can use this feature to simulate an inner class.
 
To make things a little more interesting the inner class in the following example also inherits from the outer class. In fact inheritance is the only way for the inner class to access the outer class's instance methods ''directly'' as it is otherwise treated the same as a non-nested class. The only advantage it really offers is to encapsulate closely related classes under the one umbrella .
<syntaxhighlight lang="ecmascript">class Outer {
static makeInner {
9,482

edits