xtd 0.2.0
Loading...
Searching...
No Matches
enumerable_to_list.cpp

Shows how to use xtd::linq::enumerable::to_list method.

#include <xtd/xtd>
auto main() -> int {
array<string> fruits = {"apple", "passionfruit", "banana", "mango", "orange", "blueberry", "grape", "strawberry"};
list<size_t> lengths = fruits.select<size_t>([](const string& fruit) {return fruit.length();}).to_list();
for (auto length : lengths)
console::write_line(length);
}
// This code produces the following output :
//
// 5
// 12
// 6
// 5
// 6
// 9
// 5
// 10