2015-09-13 05:28:39 +00:00
|
|
|
(ns koans.20-java-interop
|
2014-05-02 21:37:11 +00:00
|
|
|
(:require [koan-engine.core :refer :all]))
|
2014-01-26 00:04:22 +00:00
|
|
|
|
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)))
|