Sha256: 805ace2df235686afbddc180ec39ba9d8ed36014f78952dc215d3ae382b00458

Contents?: true

Size: 794 Bytes

Versions: 17

Compression:

Stored size: 794 Bytes

Contents

(defn parting
  "returns a String parting in a given language"
  ([] (parting "World"))
  ([name] (parting name "en"))
  ([name language]
    ; condp is similar to a case statement in other languages.
    ; It is described in more detail later.
    ; It is used here to take different actions based on whether the
    ; parameter "language" is set to "en", "es" or something else.
    (condp = language
      "en" (str "Goodbye, " name)
      "es" (str "Adios, " name)
      (throw (IllegalArgumentException.
        (str "unsupported language " language))))))

(println (parting)) ; -> Goodbye, World
(println (parting "Mark")) ; -> Goodbye, Mark
(println (parting "Mark" "es")) ; -> Adios, Mark
(println (parting "Mark", "xy")) ; -> java.lang.IllegalArgumentException: unsupported language xy

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
agile-proxy-0.1.24 assets/ui/bower_components/ace-builds/demo/kitchen-sink/docs/clojure.clj
agile-proxy-0.1.23 assets/ui/bower_components/ace-builds/demo/kitchen-sink/docs/clojure.clj
agile-proxy-0.1.22 assets/ui/bower_components/ace-builds/demo/kitchen-sink/docs/clojure.clj
agile-proxy-0.1.21 assets/ui/bower_components/ace-builds/demo/kitchen-sink/docs/clojure.clj
agile-proxy-0.1.20 assets/ui/bower_components/ace-builds/demo/kitchen-sink/docs/clojure.clj
agile-proxy-0.1.19 assets/ui/bower_components/ace-builds/demo/kitchen-sink/docs/clojure.clj
agile-proxy-0.1.18 assets/ui/bower_components/ace-builds/demo/kitchen-sink/docs/clojure.clj
agile-proxy-0.1.13 assets/ui/bower_components/ace-builds/demo/kitchen-sink/docs/clojure.clj
agile-proxy-0.1.12 assets/ui/bower_components/ace-builds/demo/kitchen-sink/docs/clojure.clj
agile-proxy-0.1.11 assets/ui/bower_components/ace-builds/demo/kitchen-sink/docs/clojure.clj
agile-proxy-0.1.10 assets/ui/bower_components/ace-builds/demo/kitchen-sink/docs/clojure.clj
agile-proxy-0.1.9 assets/ui/bower_components/ace-builds/demo/kitchen-sink/docs/clojure.clj
agile-proxy-0.1.8 assets/ui/bower_components/ace-builds/demo/kitchen-sink/docs/clojure.clj
agile-proxy-0.1.7 assets/ui/bower_components/ace-builds/demo/kitchen-sink/docs/clojure.clj
agile-proxy-0.1.6 assets/ui/bower_components/ace-builds/demo/kitchen-sink/docs/clojure.clj
agile-proxy-0.1.5 assets/ui/bower_components/ace-builds/demo/kitchen-sink/docs/clojure.clj
agile-proxy-0.1.4 assets/ui/bower_components/ace-builds/demo/kitchen-sink/docs/clojure.clj