September 2018
Intermediate to advanced
398 pages
9h 43m
English
In order to keep SimulatePlanApp.strMain small and readable, we are going to extract the code that is in charge of calling RetCalc.simulatePlan and return a human-readable string detailing the result of the simulation. We call this new function strSimulatePlan, and use it as shown in the following code:
def strSimulatePlan(returns: Returns, nbOfYearsSaving: Int, params: RetCalcParams): RetCalcResult[String] = { RetCalc.simulatePlan( returns = returns, params = params, nbOfMonthsSavings = nbOfYearsSaving * 12 ).map { case (capitalAtRetirement, capitalAfterDeath) => val nbOfYearsInRetirement = params.nbOfMonthsInRetirement / 12 s""" |Capital after $nbOfYearsSaving years of savings: ${capitalAtRetirement.round} ...
Read now
Unlock full access