'Could you share with me information about [...] in Dart?
I've solved several solutions on Codewars and saw that one solution uses [...], I tried to google what it is, but google only finds how to create arrays (List a = [1, 2, 3]), how to get the second element, etc.
Solution: List<int> reverseList(List<int> list)=>[...list.reversed];
Solution 1:[1]
in Dart when we use the three dots (...) it means that we are unpacking one and taking its values and throwing it, so when we have
List<int> reverseList(List<int> list)=>[...list.reversed]
means that we take the reverse list, unpack it and throw it in another List that you are creating
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Miguel Vieira Colombo |
