0
prolbem是我希望這個函數返回選項值(以Option [None]的形式)或Option [something],但它只返回一個Unit。我錯過了什麼?斯卡拉返回選項值
def intersection(another: Interval){
var test: Option[Interval] = None
if (this.isLaterThan(another) || another.isLaterThan(this)){
test
}
else {
val a = this.start.later(another.start)
val b = this.end.earlier(another.end)
test=Some(new Interval(a, b))
test
}