0
$\begingroup$

I would like to define a function that shuts up all warnings.

My first go was:

Silence[x_] := Block[{}, Quiet[x]];

I have also tried working with pure functions:

Silence = Block[{},Quiet[#]]&;

But neither of them seem to work when applied as a function (Silence), whereas they work when I write them down explicitly. Why?

$\endgroup$
2
  • 3
    $\begingroup$ Specifically speaking, just use Attributes@Silence = HoldAll; Silence[x_] := Block[{}, Quiet[x]]; or Silence = Function[x, Block[{}, Quiet[x]], HoldAll]; :) $\endgroup$
    – xzczd
    Jan 3, 2017 at 12:54
  • $\begingroup$ @xzczd Thanks a lot! $\endgroup$ Jan 3, 2017 at 14:03

0