The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

jmgimeno (69) [Avatar] Offline
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 (116) [Avatar] Offline
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.