DND DSL

This comes from the Venkat DSL screencast. Not that you can’t type yourself, but it shows a different way to do a DSL than most people think about

thePlayers = [:]

def players(String[] args) {
args.each {player ->
thePlayers[player] = 0
}
}

def getPrint_dice() {
thePlayers.each {player, dice ->
println “${player} rolled ${dice}”
}
}

def invokeMethod(String name, args) {
thePlayers[name] = args[0]
}

players ‘tim’, ‘brian’, ‘barry’

tim 5
brian 3
barry 4

print_dice

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: