Created
April 14, 2020 11:58
-
-
Save jaripekkala/dcdc41574fcab44c98d44eceded1846a to your computer and use it in GitHub Desktop.
Mixins
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
void main() { | |
final dev = Developer(); | |
dev.speak(); | |
final mgr = Manager(); | |
mgr.speak(); | |
} | |
abstract class Person { | |
String get saying; | |
void speak(); | |
} | |
mixin LoudSpeak implements Person { | |
void speak() { | |
print(saying.toUpperCase()); | |
} | |
} | |
class Developer with LoudSpeak implements Person { | |
final String saying = 'foo'; | |
} | |
class Manager with LoudSpeak implements Person { | |
final String saying = 'testi'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment