Skip to content

Commit 56fbf01

Browse files
committed
Fixes to doc page
1 parent 1cba611 commit 56fbf01

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

docs/docs/reference/other-new-features/open-classes.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,26 @@ An `open` modifier on a class signals that the class is planned for extensions.
88
// File Writer.scala
99
package p
1010

11-
open class Writer[T] with
11+
open class Writer[T] {
1212

1313
/** Sends to stdout, can be overridden */
1414
def send(x: T) = println(x)
1515

1616
/** Send all arguments using `send` */
1717
def sendAll(xs: T*) = xs.foreach(send)
18-
18+
}
1919

2020
// File EncryptedWriter.scala
2121
package p
2222

23-
class EncryptedWriter[T: Encryptable] extends Writer[T] with
23+
class EncryptedWriter[T: Encryptable] extends Writer[T] {
2424
override def send(x: T) = super.send(encrypt(x))
25+
}
2526
```
2627
An open class typically comes with some documentation that describes
2728
the internal calling patterns between methods of the class as well as hooks that can be overridden. We call this the _extension contract_ of the class. It is different from the _external contract_ between a class and its users.
2829

29-
Classes that are not open can still be extended, but only if one of two alternative conditions hold:
30+
Classes that are not open can still be extended, but only if at least one of two alternative conditions is met:
3031

3132
- The extending class is in the same source file as the extended class. In this case, the extension is usually an internal implementation matter.
3233

0 commit comments

Comments
 (0)