For example:
class BankAccount attr_accessor :amount def initialize amount @amount = amount end def withdraw_money amount @amount -= amount end endshould be refactored to:
class BankAccount attr_accessor :amount def initialize amount @amount = amount end def withdraw_money! amount @amount -= amount end endand using it makes definitely clear, that the money is withdrawn permanently:
bank_account = BankAccount.new 1000 bank_account.withdraw_money! 200 => 800 person.amount => 800
Supported by Ruby 2.1.1
Keine Kommentare:
Kommentar veröffentlichen