开发者

What does the 'in' keyword do in F#?

I'm reading the book Expert F# from Apress and there is a snippet there that I don't truly understand:

let powerOfFour n =
    let nSquared = n * n in 开发者_开发技巧nSquared * nSquared

Console.WriteLine(powerOfFour 2)

What is the 'in' keywords doing here, and does it allow me to call a method inside of the method itself?


in is the moral equivalent of a newline after a let. This is the same as

let nSquared = n * n
nSquared * nSquared

except all on one line. You can read some more here:

http://msdn.microsoft.com/en-us/library/dd233199.aspx

which shows off many of the 'verbose' keywords that you don't need when you just let the indentation do the work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜