Skip to content

Commit 3373567

Browse files
committed
match Clojure behavior for get on string / array. Need to coerce key into int.
1 parent b06247b commit 3373567

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,11 +1574,11 @@ reduces them without incurring seq initialization"
15741574

15751575
(array? o)
15761576
(when (< k (.-length o))
1577-
(aget o k))
1577+
(aget o (int k)))
15781578

15791579
(string? o)
15801580
(when (< k (.-length o))
1581-
(aget o k))
1581+
(aget o (int k)))
15821582

15831583
(native-satisfies? ILookup o)
15841584
(-lookup o k)

src/test/cljs/cljs/core_test.cljs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2829,6 +2829,9 @@
28292829
(is (= (reduce my-conj [] (eduction (map identity) [1 2 3]))
28302830
[1 2 3])))
28312831

2832+
(deftest test-get-string-float
2833+
(is (= (get "hi" 1.7) \i)))
2834+
28322835
(comment
28332836
;; ObjMap
28342837
;; (let [ks (map (partial str "foo") (range 500))

0 commit comments

Comments
 (0)