For a clear novelty, here is an overloaded operator that works for tuples of any * size.
let (@) t idx = match t.GetType().GetProperty(sprintf "Item%d" idx) with | null -> invalidArg "idx" "invalid index" | p -> p.GetValue(t, null) |> unbox //Usage let t = 4, 5, 6 let n1 : int = t@1 //4 let i = 2 let n2 = t@i //5
* Any, in this context, has a more limited meaning, in particular, up to 7.
source share