Created
December 15, 2010 17:16
-
-
Save sergiolopes/742289 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
var conta = new Conta(900) | |
var cliente = new Cliente() | |
// DSL bacana | |
cliente debita 500 da conta | |
println(conta saldo) | |
// classes | |
class Cliente { | |
def debita(valor: Int) = new Debito(valor, this) | |
class Debito(val valor: Int, val cliente: Cliente) { | |
def da (conta: Conta) = { | |
conta.saldo -= valor; | |
cliente | |
} | |
} | |
} | |
class Conta(var saldo: Int) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment