Skip to content

Commit d2529c2

Browse files
authored
Merge pull request #193 from emarukyan/master
fix contract function type in comments
2 parents aea00f1 + 62bc8a5 commit d2529c2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,16 +343,16 @@ const predicate = (a) => a > 2
343343
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.
344344

345345
```js
346-
// Define our contract : int -> int
346+
// Define our contract : int -> boolean
347347
const contract = (input) => {
348348
if (typeof input === 'number') return true
349-
throw new Error('Contract violated: expected int -> int')
349+
throw new Error('Contract violated: expected int -> boolean')
350350
}
351351

352352
const addOne = (num) => contract(num) && num + 1
353353

354354
addOne(2) // 3
355-
addOne('some string') // Contract violated: expected int -> int
355+
addOne('some string') // Contract violated: expected int -> boolean
356356
```
357357

358358
## Category

0 commit comments

Comments
 (0)