Skip to content

Instantly share code, notes, and snippets.

@Bennyelg
Created September 15, 2018 09:46
Show Gist options
  • Save Bennyelg/87d096082e8863eed520c968ff1c6f42 to your computer and use it in GitHub Desktop.
Save Bennyelg/87d096082e8863eed520c968ff1c6f42 to your computer and use it in GitHub Desktop.
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