On Oct 16, 5:13 pm, Timothy Pratley <
timothyprat...@gmail.com> wrote:
> Maybe something along these lines?
>
> (defn myreplace [str [a b]]
> (.replace str a b))
> (myreplace target search-replace)
> -> "heo world"
Same problem - it doesn't work within a doto block. This is where
JRuby-style reopening of the class and adding another method would be
handy. Here's an example from an app I'm currently writing, which
illustrates what I want to do:
(defn inner-square [i j]
(+ i 1) (+ j 1) (- scale 1) (- scale 1))
(defmacro in-square [[i j] bg x y & body]
`(let [[~i ~j] (topleft ~x ~y)]
(doto ~bg
~@body)))
(defn fill-square [bg x y color]
(in-square [i j] bg x y
(setColor color)
(fillRect (+ i 1) (+ j 1) (- scale 1) (- scale 1))))
Note that in fill-square I can either use in-square or inner-square,
but not both - in-square wraps everything in a doto block, and
fillRect expects an inline list of parameters.
martin