Reputation: 2056
So I have a class with a curried method
class myClass {
constructor () {}
curry (a,b) {
return (a,b) => {}
}
}
Now can create another method with the curry? Something like this
class myClass {
constructor () {}
curry (a,b) {
return (a,b) => {}
}
newMethod = curry()
}
Upvotes: 1
Views: 1265
Reputation: 665276
Yes, you can easily do that - just put it in the constructor:
class MyClass {
constructor() {
this.newMethod = this.curriedMethod('a') // partial application
}
curriedMethod(a) {
return (b) => {
console.log(a,b);
}
}
}
let x = new MyClass();
x.newMethod('b')
Upvotes: 5