使用模組向現有模組和型別新增新功能
模組可用於向現有模組和型別新增新功能。
namespace FSharp.Collections
module List =
let pair item1 item2 = [ item1; item2 ]
然後可以呼叫新函式,就好像它是 List 的原始成員一樣。
open FSharp.Collections
module Testing =
let result = List.pair "a" "b"
// result is a list containing "a" and "b"