Here is the original code block for ClojureScript's string "replace" function:
(defn replace
"Replaces all instance of match with replacement in s.
match/replacement can be:
string / string
pattern / (string or function of match)."
[s match replacement]
(cond
(string? match)
(.replace s (js/RegExp. (gstring/regExpEscape match) "g") replacement)
(instance? js/RegExp match)
(if (string? replacement)
(replace-all s match replacement)
(replace-all s match (replace-with replacement)))
:else (throw (str "Invalid match arg: " match))))
As you can see on this line:[s match replacement], this method accepts three arguments.
From my REPL:
user=> (replace ":c41120" ":" "")
ArityException Wrong number of args (3) passed to: core/replace clojure.lang.AFn.throwArity (AFn.java:429)
Am I the only one who thinks I have passed the correct number of arguments (3)? Any idea why this is failing?
Question, Part II: Getting Specific
In my components.cljs file, I have these 'requires':
(ns labrador.components
(:require [re-frame.core :as rf]
[reagent.core :refer [atom]]
[clojure.string :as s]
[labrador.helpers :as h]))
I've had success using "s/join" and "s/blank?" in this file. But when I try using "s/replace" like below (note that the "replace" call is on line 484):
(for [roll-count order-item-roll-counts]
(let [key (key roll-count)
val (val roll-count)
code (s/replace key ":" "")]
...I get the following error:
Uncaught TypeError: s.replace is not a function
at clojure$string$replace (string.cljs?rel=1489020198332:48)
at components.cljs?rel=1489505254528:484
...And when I explicitly call the replace function, like so:
code (clojure.string/replace key ":" "")]
...I still get the exact same error, as if I'm still calling "s/replace."
I'm new to Clojure/ClojureScript, so bare with my apparent ignorance.