Skip to content

Commit f58ca41

Browse files
committed
minor updates related to clojure 1.12
Signed-off-by: Sean Corfield <sean@corfield.org>
1 parent 95d4737 commit f58ca41

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

content/md/articles/cookbooks/parsing_xml_with_zippers.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Github](https://github.com/clojure-doc/clojure-doc.github.io).
1111

1212
## What Version of Clojure Does This Guide Cover?
1313

14-
This guide covers Clojure 1.11 and Leiningen 2.x.
14+
This guide covers Clojure 1.12 and Leiningen 2.x.
1515

1616

1717
## Overview
@@ -271,14 +271,14 @@ Now let's fill in the `file->map` function:
271271
```clojure
272272
(defn segment->map
273273
[seg]
274-
{:bytes (Long/valueOf (zip-xml/attr seg :bytes))
275-
:number (Integer/valueOf (zip-xml/attr seg :number))
274+
{:bytes (parse-long (zip-xml/attr seg :bytes))
275+
:number (parse-long (zip-xml/attr seg :number))
276276
:id (zip-xml/xml1-> seg zip-xml/text)})
277277

278278
(defn file->map
279279
[file]
280280
{:poster (zip-xml/attr file :poster)
281-
:date (Long/valueOf (zip-xml/attr file :date))
281+
:date (parse-long (zip-xml/attr file :date))
282282
:subject (zip-xml/attr file :subject)
283283
:groups (vec (zip-xml/xml-> file :groups :group zip-xml/text))
284284
:segments (mapv segment->map
@@ -433,7 +433,7 @@ achieve this using our general function:
433433
:file
434434
:segments
435435
:segment
436-
(attr-fn :number > 75 #(Long/valueOf %))
436+
(attr-fn :number > 75 parse-long)
437437
zip-xml/text)
438438
```
439439

@@ -442,7 +442,7 @@ Let's provide a helper for this to make the syntax clearer:
442442
```clojure
443443
(defn attr>
444444
[attrname val]
445-
(attr-fn attrname > val #(Long/valueOf %)))
445+
(attr-fn attrname > val parse-long))
446446

447447
(zip-xml/xml-> root
448448
:file

content/md/articles/language/interop.md

+8
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ a regular Clojure function:
158158

159159
## How to Invoke Java Methods
160160

161+
This guide does not cover type hints. See the official
162+
[Java interop type hints](https://clojure.org/reference/java_interop#typehints)
163+
and [param-tags reference](https://clojure.org/reference/java_interop#paramtags)
164+
documentation for more details (since this area changed significantly in Clojure 1.12).
165+
161166
### Instance Methods
162167

163168
Instance methods are invoked using the `.` special form:
@@ -208,6 +213,8 @@ a regular Clojure function:
208213
;;⇒ (true false false)
209214
```
210215

216+
> Note: Clojure 1.11 introduced `parse-boolean` but it is somewhat stricter than `Boolean/valueOf` and will return `nil` for strings it does not recognize, including `"TRUE"` and `"FALSE"` (which `Boolean/valueOf` does recognize).
217+
211218
### Chained Calls With The Double Dot Form
212219

213220
It is possible to chain method calls using the `..` special form:
@@ -413,6 +420,7 @@ but prior to 1.12, you had to use `Class/forName` and the internal name of the a
413420
</tr>
414421
<tr>
415422
<td><pre>"[Z"</pre></td>
423+
<td>boolean</td>
416424
<td>boolean/1</td>
417425
</tr>
418426
</tbody>

0 commit comments

Comments
 (0)