2013-05-14 23 views

回答

1

訪問不支持默認設置,因爲它需要訪問時綁定的特定內容。相反,你可以寫出一個真正匹配一切的模式。例如:

visit(sometree) { 
    case node x : handleAllTreeLikeThings(x); 
    case str y(value x, value y) : handleAllBinaryTrees(y, x, y); 
    case value x : handleAllValuesWhatsoever(x); 
} 
+0

太棒了!雖然在訪問中使用默認值,就像我的例子一樣,編譯和運行!意想不到的行爲(對我來說至少)。 – 2013-05-16 10:09:20

+0

這裏解釋了缺少的投訴:http://stackoverflow.com/questions/16164843/why-are-static-type-errors-in-this-example-code-only-reported-at-run-time-by- RAS/16165202#16165202 – jurgenv 2013-05-16 11:45:41

相關問題