Search code examples
dartcurrying

How do I find the return type of this curried function?


addition(int a) => (int b) => (int c) => a+b+c;

This is the function which returns dynamic for now

when I call addition(1)(2)(3) it prints 6 that's fine

I want to know the exact return type of this function

I am trying out the currying concept!!


Solution

  • As Rahul say's, the current type, of the returned value, in your example would be dynamic. But if we want to apply a static know type it would be something like:

    int Function(int) Function(int) addition(int a) =>
        (int b) => (int c) => a + b + c;
    
    void main() {
      print(addition.runtimeType);
      // (int) => (int) => (int) => int
    }