I figured it out. I assumed it was some quirk with defrecord, but it was
an arity exception. Didn't pass 2 params to the ctor.
DERP!
;; This is the right way:
(Vec2. (+ (:x this) (:x other))
(+ (:y this) (:y other)))
On Wednesday, 31 July 2013 17:51:36 UTC-7, JvJ wrote:
>
> I tried
The constructor should be available, like in this contrived sample:
Clojure 1.5.1
user=> (deftype Foo [a] Object (toString [this] (Foo. 1)))
user.Foo
What error are you getting?
On Wednesday, July 31, 2013 5:51:36 PM UTC-7, JvJ wrote:
>
> I tried to define this record, but the Vec2. constructor
I tried to define this record, but the Vec2. constructor doesn't exist yet.
How can I use the constructor inside the record's method?
(defrecord Vec2 [x y]
Vector
(mag [this]
(Math/sqrt
(+ (* x x) (* y y
(v+ [this] this)
(v+ [this other]
(Vec2. (+ (:x this) (