jmgimeno (67) [Avatar] Offline
#1
In this section of chapter 5 (sorry, but the listing has no numbering) we have:

val close: Account => Account = {_.copy {dateOfClosing = Some(today)}}

def close(no: String, closeDate: Option[Date]) = for {
_ <- update(no, close)
a <- query(no)
} yield a

I have two problems:
- closeDate is never used (so the Account is always closed with today's date)
- Why do you a query after the update? I suppose it is to propagate possible errors in the repository, but I'm not sure.

Thanks !!!
Debasish Ghosh (111) [Avatar] Offline
#2
Thanks for pointing out .. here's my response ..

(a) closeDate is never used. True. To make the example simple I assumed a close date of today. Will remove the closeDate from the argument.
(b) The query after the close is just to return the closed account. It's just a sample DSL and I defined the semantics that way. Note it's not an error - it will return the closed account.

Thanks.