# functional-chaning

1 min read, 59 words functionalchaningcurrying
class AddNumbers {
  private n: number;

  constructor(start = 0) {
    this.n = start;
  }

  public add(inc = 1) {
    this.n = this.n + inc;
    return this;
  }

  public print() {
    console.log(this.n);
    return this;
  }
}

// Here it is in action:

new AddNumbers(2)
  .add(3)
  .add()
  .print()
  .add(1);

Method chaining vs currying (opens new window)

Subscribe to our Newsletter

If you like my work and think it was helpful kindly support my work


Buy Me A Coffee