I am a newb to F#, just began learning it this afternoon.
What I've noticed is that when getting type info via the fsi, I get the following info:
val it : (char list -> string -> string list) = <fun:clo@0>
If I understand correctly, the (char list -> string -> string list) means that the function takes a list of char and returns a function that takes a string and returns a list of string.
However, I don't understand the usage of the "it".
Thanks for any info!
In the F# interactive command line, "it" is an identifier that gets bound to the last expression evaluated. For example:
> let a = 5;;
val a : int = 5
> a;;
val it : int = 5
> it;;
val it : int = 5
>
It's not a keyword. Here's the F# keyword list.
Info on the val keyword:
The val keyword is used to declare a field in a class or structure type without initializing it. Fields declared in this manner are called explicit fields.
[ static ] val [ mutable ] [ access-modifier ] field-name : type-name
So the it normally is the field name.
In the interactive console it's the return value (val) (the name is irrelevant, they just call it "it"):
> System.Console.ReadLine();;
Test
val it : string = "Test"
> it;;
val it : string = "Test"
"it" is sometimes used as a placeholder argument name (for example, arguments to anonymous blocks). It's (no pun intended ;-) just a convention AFAIK.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With