right, wrong, better?
Ned Konz
ned at bike-nomad.com
Mon Aug 14 00:00:25 UTC 2000
"montgomery f. tidwell" wrote:
> totalReceivedFrom: source
> (incomes includeskey: source)
> ifTrue: [^incomes at: source]
> ifFalse: [^0]
>
> totalSpentFor: reason
> (expenditures includeskey: reason)
> ifTrue: [^expenditures at: reason]
> ifFalse: [^0]
Usually we'd write something like:
totalReceivedFrom: source
^incomes at: source ifAbsent: [ 0 ]
totalSpentFor: reason
^expenditures at: reason ifAbsent: [ 0 ]
where if you look at the definition for at:ifAbsent: it
would look like your code.
--
Ned Konz
currently: Stanwood, WA
email: ned at bike-nomad.com
homepage: http://bike-nomad.com
More information about the Squeak-dev
mailing list
|