6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ClojureでJavaの無名クラスを使うにはreifyする

Last updated at Posted at 2013-09-12

UIを扱うJavaコードでよく出て来るanonymous class 無名クラス Clojureで扱うときはreifyを使う.

selectedItems.addListener(new ListChangeListener<String>() {
    @Override
    public void onChanged(Change<? extends String> change) {
        System.out.println(change.getList());
    }
});

これが

(.. selectedItems (addListener (reify ListChangeListener
                                 (onChanged [this change]
                                            (println (.. change getList))))))

こうなる

reify: 〈抽象観念などを〉具象化する,具体化して考える.
reifyの意味 - 英和辞典 Weblio辞書

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?