Update monad example (#115)

Monad description mentions 'of' function; update the example to use this.
This commit is contained in:
Iain Diamond 2016-09-10 06:39:05 +01:00 committed by hemanth.hm
parent 52b9f361b6
commit e918b396ec

View file

@ -488,10 +488,10 @@ Array.prototype.chain = function (f) {
}
// Usage
;['cat,dog', 'fish,bird'].chain((a) => a.split(',')) // ['cat', 'dog', 'fish', 'bird']
;Array.of('cat,dog', 'fish,bird').chain((a) => a.split(',')) // ['cat', 'dog', 'fish', 'bird']
// Contrast to map
;['cat,dog', 'fish,bird'].map((a) => a.split(',')) // [['cat', 'dog'], ['fish', 'bird']]
;Array.of('cat,dog', 'fish,bird').map((a) => a.split(',')) // [['cat', 'dog'], ['fish', 'bird']]
```
`of` is also known as `return` in other functional languages.