4 ms·
I find this style (Rust)) more readable end easier to extend: RangeInclusive::new(1, 10) .filter(|x| x % 2 == 0) .for_each(|x|{ println!("{}", x); });
by fiedzia 6y ago
I find this style (Rust)) more readable end easier to extend:
RangeInclusive::new(1, 10)
.filter(|x| x % 2 == 0)
.for_each(|x|{ println!("{}", x); });
(though you could write it the same way, for i in 1..=-10 { if .. { .. }}
- viktorcode 6y agoThe same can be written in Swift as (1...10).filter { $0.isMultiple(of: 2) }.forEach { print($0) }