Re:Swift System Is Now Open Source
by viktorcode on Saturday September 26, 2020 @02:15AM
(#24596799)
The same can be written in Swift as
(1...10).filter { $0.isMultiple(of: 2) }.forEach { print($0) }
(1...10).filter { $0.isMultiple(of: 2) }.forEach { print($0) }
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 .. { .. }}