我想创建一个表示成功或失败的变量。
Enumeration
是做这种事情的最好方法吗?
object Result extends Enumeration {
val Fail = Value(0)
val Success = Value(1)
}
我的用例是变量将是case类的一部分。
case class JsonResult (result: Result)
此JSON将发送到client.Eg
{
result: 1
}
答案 0 :(得分:0)
MySpecialFailure
这更灵活,因为将MySpecialSuccess
和case class MySpecialFailure(message: String) extends MySpecialResult
更改为类更容易,例如,如果要将一些错误消息附加到失败案例,则可以将其替换为案例类:
scala.util.{Either, Left, Right}
也许您可以使用具体的子类Try
和Success
来查看Failure
和### Plot each list
```{r plotSWBS6IByPhaseAndWave, echo=TRUE, eval=TRUE}
plotList <- list()
for(i in 1:length(seriesFigureSaleDataBS6I_PhaseWave)) {
plotList[[i]] <- plot_ly(data = seriesFigureSaleDataBS6I_PhaseWave[[i]],
x = ~priceDate,
y = ~amount,
color = ~actionFigurePackageName,
colors = "Pastel2",
type = "scatter",
mode = "markers") %>%
layout(title = paste("Phase", seriesFigureSaleDataBS6I_PhaseWave[[i]]$Phase, "& Wave", seriesFigureSaleDataBS6I_PhaseWave[[i]]$Wave))
}
# p <- lapply(seriesFigureSaleDataBS6I_PhaseWave, function(phaseWaveRow) plot_ly(data = phaseWaveRow, x = ~priceDate, y = ~amount, color = ~actionFigureUniqueId, colors = "Pastel2"))
print(class(seriesFigureSaleDataBS6I_PhaseWave))
print(summary(seriesFigureSaleDataBS6I_PhaseWave))
#rm(seriesFigureSaleDataBS6I_PhaseWave)
plotList
```
以获取灵感。