clojure-koans/src/koans/20_java_interop.clj

20 lines
705 B
Clojure
Raw Normal View History

(ns koans.20-java-interop
(:require [koan-engine.core :refer :all]))
2011-07-08 20:57:44 +00:00
(meditations
"You may have done more with Java than you know"
2023-01-04 16:15:43 +00:00
(= java.lang.String (class "warfare")) ; hint: try typing (javadoc "warfare") in the REPL
2011-07-08 20:57:44 +00:00
"The dot signifies easy and direct Java interoperation"
2023-01-04 16:15:43 +00:00
(= "SELECT * FROM" (.toUpperCase "select * from"))
2011-07-08 20:57:44 +00:00
"But instance method calls are very different from normal functions"
2023-01-04 16:15:43 +00:00
(= ["SELECT" "FROM" "WHERE"] (map #(.toUpperCase %) ["select" "from" "where"]))
2011-07-08 20:57:44 +00:00
"Constructing might be harder than breaking"
2023-01-04 16:15:43 +00:00
(= 10 (let [latch (java.util.concurrent.CountDownLatch. 10)]
2011-07-08 20:57:44 +00:00
(.getCount latch)))
"Static methods are slashing prices!"
2023-01-04 16:15:43 +00:00
(== 1024 (Math/pow 2 10)))