Skip to content

Commit 3f5309e

Browse files
author
Bozhidar Batsov
committed
suggested the use of the sugared interop forms
1 parent d0019ef commit 3f5309e

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,45 @@ compile time constants.
405405

406406
* Use `(inc x)` & `(dec x)` instead of `(+ x 1)` and `(- x 1)`.
407407

408+
* Use the sugared Java interop forms.
409+
410+
```Clojure
411+
;;; object creation
412+
;; good
413+
(java.util.ArrayList. 100)
414+
415+
;; bad
416+
(new java.util.ArrayList 100)
417+
418+
;;; static method invocation
419+
;; good
420+
(Math/pow 2 10)
421+
422+
;; bad
423+
(. Math pow 2 10)
424+
425+
;;; instance method invocation
426+
;; good
427+
(.substring "hello" 1 3)
428+
429+
;; bad
430+
(. "hello" substring 1 3)
431+
432+
;;; static field access
433+
;; good
434+
Integer/MAX_VALUE
435+
436+
;; bad
437+
(. Integer MAX_VALUE)
438+
439+
;;; instance field access
440+
;; good
441+
(.someField some-object)
442+
443+
;; bad
444+
(. some-object some-field)
445+
```
446+
408447
## Naming
409448

410449
> The only real difficulties in programming are cache invalidation and

0 commit comments

Comments
 (0)