函数式编程(误)
代码 -- 函数式编程
function test (x) {
this.__value = x;
}
test.prototype.of = function (x) {
return new test(x)
}
test.prototype.isValid = function () {
this.__value = this.__value >>> 0
return this.__value
}
test.prototype.map = function (v) {
return this.isValid() ? this.of(v(this.__value)) : this.of("-");
}
console.log(new test(2**32).map(v => (v === 1 ? '一课' : '主题')).__value)
// output : '-'
// 1 => '一课', not 1 => '主题'
本文来自博客园,作者:MerLin97,转载请注明原文链接:https://www.cnblogs.com/merlin97/p/15213469.html