Scala暗示练习

时间:2017-10-16 19:20:18

标签: scala

我正在从https://www.scala-exercises.org/std_lib/implicits

开始练习

对于以下问题,我的回答似乎不正确,但我不知道为什么。

object MyPredef {

  class KoanIntWrapper(val original: Int) {
    def isOdd = original % 2 != 0

    def isEven = !isOdd
  }

  implicit def thisMethodNameIsIrrelevant(value: Int) =
    new KoanIntWrapper(value)
}

import MyPredef._
//imported implicits come into effect within this scope
19.isOdd should be(true) //my answer but it seem incorrect
)
20.isOdd should be(false)  //my answer but it seem incorrect

错误为There was a problem evaluating your answer, please try again later.

1 个答案:

答案 0 :(得分:2)

正确答案相应地为truefalse,因此您的答案是正确的。

你有额外的结束括号:

19.isOdd should be(true) //my answer but it seem incorrect
)  // <-- HERE
20.isOdd should be(false)  //my answer but it seem incorrect

学习Scala祝你好运。

现在检查这个练习,一切正常。所以这似乎是一个暂时的问题。

enter image description here