Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. # thread-first ## Navigation [[thread-first]] `->` is ideal for navigating large, nested structures. <code clojure> (-> results :matches (nth 3) :scores (get "total_points")) </code> This works with Java objects too <code clojure> (-> results .getMatches (nth 3) .getScores (.getKey "total_points")) </code> ## Transformation The second use case of `->` is performing a series of functional transformations on a single value: <code clojure> (-> username string/trim string/lower-case (string/replace #"[^a-z]" "-")) </code> <code clojure> (-> game-state (assoc :next-player :player2) (update :turn-counter inc) (update-in [:scores :player1] + 10) (update-in [:scores :player2] - 3)) </code> open/thread-first.txt Last modified: 2024/10/05 06:15by 127.0.0.1