Skip to content

5주차 : 동작임에도 Property로 선언한 이유에 대하여 #27

@white-gyu

Description

@white-gyu

📝 상세 설명

  • 동작임에도 Property로 선언한 이유에 대해 고민합니다.
class CostSummary(userCurrency: Currency) {
    private val _lines = mutableListOf<CurrencyConversion>()
    
    val total: Money = Money.of(0, userCurrency)
        private set
    
    val lines: List<CurrencyConversion> // 왜 동작임에도 Property로 선언했을까?
        get() = _lines.toList()
    
    fun addLine(line: CurrencyConversion) {
        _lines.add(line)
        total += line.toMoney
    }
}

Originally posted by @white-gyu in #24 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions