为什么我在这里运行false
方法会var x = R.ifElse(R.T, function(){
console.log("function two (onTruthy)")
// console.log(arguments)
}, function(){
console.log("function three (onFalsy)")
// console.log(arguments)
})
x(false)
log“函数二(onTruthy)”?
var x = R.pipe(
R.partialRight(R.match, true),
R.partialRight(R.ifElse, function(){
console.log("function two (onTruthy)")
// console.log(arguments)
}, function(){
console.log("function three (onFalsy)")
// console.log(arguments)
})
)
我在想这是因为R.T总是回归真实。也许使用_.isMatch我可以匹配它吗?
更新:刚试过:
Sub Test()
Dim startQuote
Dim endQuote
startQuote = InStr(Range("A1").Value, """")
endQuote = InStr(startQuote + 1, Range("A1").Value, """")
Range("B1").Value = Mid(Range("A1").Value, startQuote + 1, endQuote - startQuote - 1)
End Sub
答案 0 :(得分:3)
R.T
评估true
是否有任何输入。因此,R.ifElse(R.T, f, g)
可以简化为f
。
在我看来,您正在寻找R.ifElse(R.identity, f, g)
,但这可能会通过... ? ... : ...
更好地表达。