Created
January 26, 2017 09:28
-
-
Save rparree/d433bf628327a5e7011773231c1a7a0b to your computer and use it in GitHub Desktop.
Stackable Trait (start)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| abstract class MyStringBuilder { | |
| def get(): String | |
| def append(s: String) | |
| } | |
| class BasicStringBuilder extends MyStringBuilder { | |
| private var value : String = "" | |
| def get(): String = value | |
| def append(s: String) = value = value + s | |
| } | |
| val sb = new BasicStringBuilder | |
| sb.append("hello friend") | |
| sb.get() // hello friend |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment