A couple of questions left
Now, I have some time to write about a couple of questions I have received about F#, and their answers.
1. To get a specific element of a tuple :
If we do not want to create variables for the elements that we are not interested in of a tuple, we can use “_” for all other elements, i.e.:
let _, _, valBrand= drinks
which is interpreted into the compiler as we see in the FS Interactive window:
val valBrand : string = “Coca Cola Zero”
2. “namespace” keywords stays as is, and we can have either a module or a type [i.e. C# class] under a namespace. The example would be :
File1: Drink.fs
module Drink=
let drinks= (Coke, 0.45, “Coca Cola Zero”)
let _, _, valBrand= drinks
File2: BeverageCalculator.fs [placed under the Drink.fs if they are in the same project.]
open Vesta.Beverage.Drink
module BeverageCalculator=
let drink= valBrand
So, we can use everything from the first namespace,
Happy F# days!
[...] the presentation, there is a high probability that, you will forget to tell “I will post the answers to my blog as soon as possible” as I forgot. If you have anything you want to add, please [...]
Comments from my First Talk at ldnUG about F# « Updates from a continuous developer
May 15, 2010 at 4:01 pm