There is no range over a channel. Receive in a loop and stop when the value is nil. That works only if real messages are never nil, which the channel operations already require.
range
(require '[clojure.core.async :as async]) (def jobs (async/chan 3)) (doseq [job ["a" "b" "c"]] (async/>! jobs job)) (async/close! jobs) (loop [] (when-let [job (async/<! jobs)] (println "job" job) (recur))) (println "closed")
when-let treats the nil from a closed channel as the end.
when-let
$ glj walking-channels.glj job a job b job c closed
Next example: Timers.
A hands-on tour in the style of Go by Example. Glojure is a Clojure interpreter hosted on Go.