Home > OS >  How to use output of the first function as input for the second function in Dart
How to use output of the first function as input for the second function in Dart

Time:11-04

Just trying to tinker with the Dart, a bit. Here trying to use the Output of the first function ( which is a List) in the second function. but it prints 0, ?

void main() {
  print(secondFuncion(firstFuncion()));
}

List firstFuncion() {
  List mylist = [];
  for (var i = 0; i < 23; i  ) {
    mylist.add(i);
  }
  return mylist;
}

secondFuncion(List<mylist> b) {
  for (var element in b) {
    return element;
  }
}

CodePudding user response:

@omisha

void main() {
  secondFuncion(firstFuncion());
}

List firstFuncion() {
  List mylist = [];
  for (var i = 0; i < 23; i  ) {
    mylist.add(i);
  }
  return mylist;
}

secondFuncion(List b) {
  for (var element in b) {
    print(element);
  }
}

CodePudding user response:

As @OMI Shah said just change

    secondFuncion(List<mylist> b) {
  for (var element in b) {
    return element;
  }
}

to this

secondFuncion(List b) {
  for (var element in b) {
    print(element);
  }
}
  • Related