Загрузка страницы

Learn Clojure 19. Java Interop - Clojure Koans Walkthrough in Light Table IDE

Watch the rest: https://slatteryjim.github.io/ClojureScreencasts

This video introduces Java interop, or how you can interoperate with Java code from Clojure. The idiomatic way of accessing fields and methods on a class is to use the dot notation, e.g. (.toUpperCase "hello"). Static members simply need the classname, followed by a slash, followed by the static field or method, e.g. (MyClass/staticMethod "myarg"). Constructors are called by using a period after the class name, e.g. (MyClass. "arg1")

Lots of good followup information here:
http://clojure.org/java_interop

The Clojure Koans Walkthrough screencast tutorial helps you learn the Clojure programming language. Experience the joy of Clojure in the Light Table IDE as we tour through the Clojure Koans, taking you all the way from Beginner to Intermediate to Advanced.

Clojure Koans: http://clojurekoans.com/
On Github: https://github.com/functional-koans/clojure-koans/
Light Table IDE: http://www.lighttable.com/

Here is the 19_java_interop.clj source code:

(meditations
"You may have done more with Java than you know"
(= __ (class "warfare")) ; hint: try typing (javadoc "warfare") in the REPL

"The dot signifies easy and direct Java interoperation"
(= __ (.toUpperCase "select * from"))

"But instance method calls are very different from normal functions"
(= ["SELECT" "FROM" "WHERE"] (map ___ ["select" "from" "where"]))

"Constructing might be harder than breaking"
(= 10 (let [latch (java.util.concurrent.CountDownLatch. __)]
(.getCount latch)))

"Static methods are slashing prices!"
(== __ (Math/pow 2 10)))

Clojure is a Lisp created by Rich Hickey that runs on the JVM, as an alternative to Java. ClojureScript can target the web browser environment, and node.js, by compiling down to JavaScript, using the Google Closure compiler. Clojure features immutability, functional programming, and being a Lisp, macros.

Видео Learn Clojure 19. Java Interop - Clojure Koans Walkthrough in Light Table IDE канала slatterypod
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
15 марта 2013 г. 22:35:31
00:06:36
Яндекс.Метрика