The code a=2+2//Timing
assigns the variable a to {time,4} . How can I show the evaluation time, but still assign a with the result of 2+2 directly (in one line)?
I have tried defining a custom Timing function (working now)
showTiming[in_] := Block[{res}, res = Timing[in]; Print[res[[1]], " s"]; res[[2]] ]
SetAttributes[showTiming, HoldAll] (* <- IMPORTANT!*)
a=2+2//showTiming

a = FactorInteger[Times @@ RandomPrime[2^70, 2]]– flinty May 21 '21 at 12:41