May 2018
Beginner to intermediate
290 pages
6h 43m
English
To see how we can get at the wonders of Java from Clojure, let’s reach for every programmer’s favorite abstraction, the file. Java comes packaged with a handy class for representing files, namely java.io.File. According to the documentation for java.io.File, we can create an instance by passing in a string, the path to the file. To create a new instance of a Java class using Clojure’s interoperation facilities—interop for short—we use the classname with a dot on the end in the lead-off spot in the expression:
| | (def authors (java.io.File. "authors.txt")) |
The preceding code will create a new instance of java.io.File, calling the constructor along the way, and return that instance—which represents ...
Read now
Unlock full access