Created
September 15, 2018 09:46
-
-
Save Bennyelg/87d096082e8863eed520c968ff1c6f42 to your computer and use it in GitHub Desktop.
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
type | |
User = ref object | |
name: string | |
paymentStrategy: proc () | |
proc strategyA() = | |
echo("strategyA") | |
proc strategyB() = | |
echo("strategyB") | |
var user = User(name: "SpoiledUser", paymentStrategy: strategyA) | |
user.paymentStrategy() | |
user.paymentStrategy = strategyB | |
user.paymentStrategy() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment