我有Clojure函数,它返回LazySeq。当我从REPL运行此功能时,它工作正常。但是,如果我尝试从Java代码中调用相同的函数,如下所示:

Object result = com.acme.forecast.core.runforecast("file1.csv", "file2.txt");

我得到以下异常:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException:
  clojure.lang.LazySeq cannot be cast to java.lang.Number
    at com.acme.forecast.core.runforecast(Unknown Source)
    at com.acme.forecast.client.gui.ClientGUI.actionPerformed(ClientGUI.java:180)

我的一代人说我要返回的是LazySeq,而不是数字:
  (:gen-class
    :name com.acme.forecast.core
    :methods [#^{:static true} [runforecast [String String] clojure.lang.LazySeq]])

这是怎么了?

最佳答案

该错误确实表明您正在返回LazySeq。问题是它试图存储在Number中,尽管我看不到此代码段的位置。

09-25 22:15