wjlow/intro-to-scala

Introduce `flatMap` in `OptionExcercises2`

felipeeflores opened this issue · 2 comments

should we introduce flatMap on findJobIdByHumanId.

At this point people understand what an Option type is and how/when to use it. findJobIdByHumanId is a very good example of how you combine two Options. The IDE suggest that you should use flatMap instead of map.flatten.

The next exercise findJobByHumanId has the same intuition. We could introduce it here to show the difference.

wjlow commented

It will be introduced.

I don't want to give them flatMap as an answer.

We want to show them this progression:

  1. map then flatten
  2. flatMap
  3. for-comprehension

It'll make more sense in person, I hope :)

Cool. I thought so.
The hints could add some intuition? Like

here we are trying to combine two options?
how could this be more concise?

But I guess that's more like a presenter note.