我正嘗試加入Dictionary<int, string>和List<MyClass>但它拋出一個錯誤 「的方法類型參數不能從使用中推斷「。 但在我看來,所有的參數都完全被定義... class Row
{
public string name { get; set; }
public string[] data { get; set; }
}
Dictionary
試圖在新元素給定點更換列表中的一個元素,然後返回元素。 setelt :: Int -> [a] -> a -> [a]
setelt x (yf:(y:yl)) z
| x == (length yf) = (yf:(z:yl))
導致此錯誤: Inferred type is not general enough
Expression : setelt
Expected t
我在尋找一個類似的推斷拍攝的泛型類型,類似於下面的方法片段的概念,但不是爲捕獲泛型類: public <X, Y, Z> static void someMethod(ObjectInterface<X, Y, Z> object) {
// code that uses inferred generic type parameters X, Y and Z...
}
的代碼在這個
爲什麼在編譯此代碼段時出現錯誤? trait ID[R <: Record[R] with KeyedRecord[Long]] {
this: R =>
val idField = new LongField(this)
}
錯誤: inferred type arguments [ID[R] with R] do not conform to class Long