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$

marked as duplicate by xzczd, Mr.Wizard Jan 3 '17 at 12:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 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 '17 at 12:54
  • $\begingroup$ @xzczd Thanks a lot! $\endgroup$ – usumdelphini Jan 3 '17 at 14:03