Reputation: 5529
I understand that bigint
is not a function but rather a type constructor. That's why this fails:
// Won't compile
let foo = 10 |> bigint
I understand that I can create a new function which accepts an integer and returns a bigint
, and then the pipeline operator will work.
However, I don't understand why this works:
let bar = bigint 10
If bigint
is a type constructor, why don't I need new
? Where exactly is bigint
defined as an alias to System.Numerics.BigInteger's constructor?
Upvotes: 10
Views: 6217
Reputation: 16782
bigint is type abberviation for System.Numerics.BigInteger so when you type
let x = bigint 10
you actually create instance of BigInteger. In F# new is optional in constructors, basically it should be used when creating instances of types that implement IDisposable
Upvotes: 9