我在看F#爲C#開發人員書,有這個功能,我似乎無法瞭解什麼是 F#不清楚功能的影響
let tripleVariable = 1, "two", "three"
let a, b, c = tripleVariable
let l = [(1,2,3); (2,3,4); (3,4,5)]
for a,b,c in l do
printfn "triple is (%d,%d,%d)" a b c
輸出 這個函數的作用
triple is (1,2,3)
triple is (2,3,4)
triple is (3,4,5)
爲什麼a
,b
,c
與tripleVariable
初始化?是否因爲需要在for
循環中知道它們的類型(或其類型,因爲它是Tuple
)?定義變量a
,b
和c
當
學究角落:他們是* *值,不變量,除非它們被標記爲「可變」。 –