diff --git a/src/exo1/exo1.ts b/src/exo1/exo1.ts index 0442bd7..08ec470 100644 --- a/src/exo1/exo1.ts +++ b/src/exo1/exo1.ts @@ -27,6 +27,17 @@ export const divide = (a: number, b: number): number => { export const safeDivide: (a: number, b: number) => Option = unimplemented; + +// You probably wrote `safeDivide` using `if` statements and it's perfectly valid! +// There are ways to not use `if` statements. +// Keep in mind that extracting small functions out of pipes and using `if` statements in them +// is perfectly fine and is sometimes more readable than not using `if`. +// +// BONUS: Try now to re-write `safeDivide` without any `if` +// +// HINT: Have a look at `fromPredicate` constructor + + /////////////////////////////////////////////////////////////////////////////// // EITHER // ///////////////////////////////////////////////////////////////////////////////