如何比较Scala中的枚举?

时间:2016-11-04 16:36:47

标签: scala enums

我还没有喜欢告诉我如何在DenseVectors中比较Scala中的枚举:

import breeze.linalg._

object StepThresholdConsideration extends Enumeration {
  type StepThresholdConsideration = Value
  val Inclusive, Strict = Value
}

val stepThresholdConsideration = DenseVector(StepThresholdConsideration.Strict, StepThresholdConsideration.Strict, StepThresholdConsideration.Inclusive)
stepThresholdConsideration :== DenseVector.fill(3, StepThresholdConsideration.Strict)
stepThresholdConsideration :== DenseVector.fill(3, StepThresholdConsideration.Inclusive)

这不起作用。为什么呢?

stepThresholdConsideration.map(_ == StepThresholdConsideration.Strict)
stepThresholdConsideration.map(_ == StepThresholdConsideration.Inclusive)

另一方面工作。

0 个答案:

没有答案