Skip to content

Commit

Permalink
第10章 エラーメッセージを少しマシなものにするためにデバック出力を編集する
Browse files Browse the repository at this point in the history
- SwiftはCustomStringConvertibleのdescriptionで、JavaのtoStringと同じ処理を実現できる
  • Loading branch information
masashi-sutou committed Jan 24, 2018
1 parent 6f5b4e8 commit a62579a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions TDDForSwift/Source/Money.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@

import Foundation

class Money: Equatable {
class Money: Equatable, CustomStringConvertible {

var amount: Int
var currency: String

var description: String

init(_ amount: Int, _ currency: String) {
self.amount = amount
self.currency = currency
self.description = String(amount) + " " + currency
}

func times(_ multiplier: Int) -> Money? {
Expand Down

0 comments on commit a62579a

Please sign in to comment.