Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Write a function that takes a list of strings and returns a new list with the order of the elements reversed.
- Example:
- Input: ["apple", "banana", "cherry"]
- Output: ["cherry", "banana", "apple"]*/
- void main()
- {
- List<String> names=["apple","banana","cherry"];
- print("The reversed List is ${revList(names)}");
- }
- List<String> revList(List<String> names1)
- {
- return names1.reversed.toList();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement