Scala操作符的重载

+操作符的重载案例:

case class TurnupMetric(turnup_num: Long,
                        turnup_users: Set[String],
                        vv: Long,
                        fuv: Set[String],
                        realvv: Long,
                        realfuv: Set[String],
                        playtime: Long
                       ) extends Serializable {
  def +(other: TurnupMetric): TurnupMetric = {
    TurnupMetric(
      turnup_num + other.turnup_num,
      turnup_users ++ other.turnup_users,
      vv + other.vv,
      fuv ++ other.fuv,
      realvv + other.realvv,
      realfuv ++ other.realfuv,
      playtime + other.playtime
    )
  }
}

你可能感兴趣的:(scala)