Sau this question Tôi tự hỏi làm thế nào (hoặc nếu) tôi có thể mở rộng loại F # Array chung. Tôi có thể làm điều này:F # làm thế nào để mở rộng loại mảng chung?
type System.Array with
member a.Last = a.GetValue(a.Length - 1)
nhưng như Tomas đã đề cập không chung chung. Tiếp theo, tôi cố gắng này, nhưng nó không hoạt động:
type Microsoft.FSharp.Collections.Array with // Error: Array is not defined
member a.Last = a.[a.Length - 1]
Trong F # scource tôi thấy không gian tên này, nhưng nó không hoạt động hoặc là:
type Microsoft.FSharp.Primitives.Basics.Array with // Error: Array is not defined
member a.Last = a.[a.Length - 1]