https://d.puremagic.com/issues/show_bug.cgi?id=12272
yebblies <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #2 from yebblies <[email protected]> 2014-03-01 01:05:44 EST --- (In reply to comment #0) > In Java8 there are functions like and() or() xor() that are handy to compose > predicates: > > Predicate<String> startsWithJ = (n) -> n.startsWith("J"); > Predicate<String> fourLetterLong = (n) -> n.length() == 4; > names.stream().filter(startsWithJ.and(fourLetterLong)) > > In D: > > auto startsWithJ = (string n) => n.startsWith("J"); > auto fourLetterLong = (string n) => n.length == 4; > names.filter!(and!(startsWithJ, fourLetterLong)) Lambdas make this pretty easy... names.filter!(s => s.startsWithJ && s.fourLetterLong) Slightly longer, but _much_ more flexible. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
