如何在Clojure gen-class方法中调用超类的方法? [英] How to invoke superclass' method in a Clojure gen-class method?
本文介绍了如何在Clojure gen-class方法中调用超类的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建一个类,该类通过 gen-class
扩展输入流Clojure。如果要调用父类的方法,该怎么做?
I'm trying to create a class that extends input stream Clojure via gen-class
. If I want to invoke the parent class' method, how do I do that?
推荐答案
从( 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.
因此,为了能够调用父级的 fooBar
方法,您会说
So, in order to be able to call the parent's fooBar
method, you'd say
(ns my.custom.Foo
(:gen-class
; ...
:exposes-methods {fooBar parentFooBar}
; ...
))
然后执行 fooBar
:
(defn -fooBar [this]
(combine-appropriately (.parentFooBar this)
other-stuff))
1 除了:gen-class $ c由
ns
表格提供的$ c>工具,有一个 gen-class
宏。
这篇关于如何在Clojure gen-class方法中调用超类的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文