clojuredesign-podcast

neumann 2023-06-12T17:52:15.903999Z

@john.t.richardson.dev Another fun trick when you have thread first (`->`) is to use doto and println

(-> {:stuff 42}
    (assoc :moooorrrrr-stuff 4242)
    (doto println)
    (dissoc :stuff))

neumann 2023-06-12T18:03:12.164919Z

You can do something similar with thread last (`->>`), but with more boilerplate.

(->> (range 1 12)
     (filter odd?)
     (#(doto % println))
     (map inc))

pez 2023-06-12T19:56:17.092039Z

And your editor probably has a command for letting you examine the thread in the REPL. With the cursors at |:

(-> {:stuff 42}
    (assoc :moooorrrrr-stuff 4242)|
    (dissoc :stuff))
In Calva you can Evaluate from Start of List to Cursor, Closing Brackets. In CIDER I think it is something like evaluate to point. Calva also has mechanisms that will let you include any previous let bindings when doing this (probably other Clojure editors can do this too).

👀 1
neumann 2023-06-12T22:20:57.355399Z

@pez Oh, that's nifty! I was not aware of that. @nate have you seen this?