我正在尝试创建一个扩展输入流Clojure的类gen-class.如果我想调用父类的方法,我该怎么做?
Mic*_*zyk 11
从(doc gen-class)1开始:
:exposes-methods {super-method-name exposed-name, ...}
It is sometimes necessary to call the superclass' implementation of an
overridden method. Those methods may be exposed and referred in
the new method implementation by a local name.
Run Code Online (Sandbox Code Playgroud)
所以,为了能够调用父fooBar方法,你会说
(ns my.custom.Foo
(:gen-class
; ...
:exposes-methods {fooBar parentFooBar}
; ...
))
Run Code Online (Sandbox Code Playgroud)
然后执行fooBar:
(defn -fooBar [this]
(combine-appropriately (.parentFooBar this)
other-stuff))
Run Code Online (Sandbox Code Playgroud)
1除了表格:gen-class提供的设施外ns,还有一个gen-class宏观.