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

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];

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

>Solution :

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

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