java.lang.Long无法强制转换为clojure.lang.IFn我不会忘记为什么我会这样做

时间:2017-03-13 15:37:00

标签: clojure

class TooHighException extends Exception {
}


class TooLowException extends Exception {
}


class CorrectException extends Exception {
}

public class HelloWorld {

public void main(String[] args) throws TooLowException, TooHighException, CorrectException {

    Random random = new Random();
    Scanner scanner = new Scanner(System.in);
    int number = random.nextInt(100);
    int guess = -1;
    while (guess != number) {
        System.out.print("Enter your guess: ");
        guess = scanner.nextInt();
        if (guess < number) {
            throw new TooLowException();
        } else if (guess > number) {
            throw new TooHighException();
        } else {
            throw new CorrectException();
        }
    }

}

我编写此代码并发现此错误,但我不明白为什么?请向我解释。

1 个答案:

答案 0 :(得分:3)

reduce的参数顺序不正确。 见https://clojuredocs.org/clojure.core/reduce