2 ms·
as-> is great for when you have to mix thread-first and thread-last. cond-> is great for building maps where some keys might not be needed: (cond-> {:k1 v
by iterati 8y ago
as-> is great for when you have to mix thread-first and thread-last.
cond-> is great for building maps where some keys might not be needed:
(cond-> {:k1 v1}
v2 (assoc :k2 v2)
...)
some-> and some->> I don't use as often, but when mixing in some java code that could throw an NPE, these will avoid that and just return nil early (they short-circuit when getting a nil value).
- dustingetz 8y agoYou can next ->> inside ->, took far too many years for me to realize: @(-> ctx :hypercrud.browser/fiddle (reactive/cursor [:fiddle/ident]) (->> (reactive/fmap name))) another (-> [10 11] (conj 12) (as-> xs (map - xs [3 2 1])) (reverse))