From b593d7c1ca70711c31d723006d8522eaac50d329 Mon Sep 17 00:00:00 2001 From: Edgar Date: Wed, 6 Feb 2019 12:47:20 +0400 Subject: [PATCH 1/2] fix contract function return type --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index c40fed8..939540c 100644 --- a/readme.md +++ b/readme.md @@ -343,7 +343,7 @@ const predicate = (a) => a > 2 A contract specifies the obligations and guarantees of the behavior from a function or expression at runtime. This acts as a set of rules that are expected from the input and output of a function or expression, and errors are generally reported whenever a contract is violated. ```js -// Define our contract : int -> int +// Define our contract : int -> boolean const contract = (input) => { if (typeof input === 'number') return true throw new Error('Contract violated: expected int -> int') From 62bc8a59f564d3efb2cc615376af2afd47d6e02e Mon Sep 17 00:00:00 2001 From: Edgar Date: Wed, 6 Feb 2019 12:49:39 +0400 Subject: [PATCH 2/2] fix contract function type --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 939540c..a4d411b 100644 --- a/readme.md +++ b/readme.md @@ -346,13 +346,13 @@ A contract specifies the obligations and guarantees of the behavior from a funct // Define our contract : int -> boolean const contract = (input) => { if (typeof input === 'number') return true - throw new Error('Contract violated: expected int -> int') + throw new Error('Contract violated: expected int -> boolean') } const addOne = (num) => contract(num) && num + 1 addOne(2) // 3 -addOne('some string') // Contract violated: expected int -> int +addOne('some string') // Contract violated: expected int -> boolean ``` ## Category