In LINQPad, what's the equivalent of the C # .Dump () method in F #?

In LINQPad, what's the equivalent of the C # .Dump () method in F #?

For example, what's the fastest way to dump the below C # in F # syntax?

var nums = new List<int> { 1, 2, 3, 4, 5 };
nums.Dump();

      

and

let nums = [1; 2; 3; 4; 5]

      

+3


source to share


4 answers


This works for me:



let nums = [1; 2; 3; 4; 5]
nums.Dump()

      

+10


source


You can also use Dump

as a function:



let nums = [1; 2; 3; 4; 5]
Dump nums
nums |> Dump
(* ... *)

      

+8


source


Apart from the method already set .Dump()

, you should know that it is also automatically called when you write the collection (and other types) in the console:

let nums = [1; 2; 3; 4; 5]
Console.WriteLine(nums);

      

will also give you a dump.

+2


source


This can be used in the middle of a workflow as well, as it returns its input.

let DumpHelper (caption:string) a =
 a.Dump(caption)
 a

      

0


source







All Articles