fix contract function return type

This commit is contained in:
Edgar 2019-02-06 12:47:20 +04:00 committed by GitHub
parent aea00f1338
commit b593d7c1ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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. 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 ```js
// Define our contract : int -> int // Define our contract : int -> boolean
const contract = (input) => { const contract = (input) => {
if (typeof input === 'number') return true if (typeof input === 'number') return true
throw new Error('Contract violated: expected int -> int') throw new Error('Contract violated: expected int -> int')