|
Java example source code file (delays.clj)
The delays.clj Java example source code(ns clojure.test-clojure.delays (:use clojure.test)) (deftest calls-once (let [a (atom 0) d (delay (swap! a inc))] (is (= 0 @a)) (is (= 1 @d)) (is (= 1 @d)) (is (= 1 @a)))) (deftest saves-exceptions (let [f #(do (throw (Exception. "broken")) 1) d (delay (f)) try-call #(try @d (catch Exception e e)) first-result (try-call)] (is (instance? Exception first-result)) (is (identical? first-result (try-call))))) Other Java examples (source code examples)Here is a short list of links related to this Java delays.clj source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.