Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading