Function Repository Resource:

EchoSet

Source Notebook

Set a value to a symbol and print them

Contributed by: Taliesin Beynon

ResourceFunction["EchoSet"][sym,value]

sets sym to value, while simultaneously printing "sym = value".

Details and Options

ResourceFunction["EchoSet"] has the attribute HoldFirst.

Examples

Basic Examples (3) 

Make an assignment:

In[1]:=
ResourceFunction["EchoSet"][x, 5]
Out[1]=

The value is stored:

In[2]:=
OwnValues[x]
Out[2]=

New assignments with identical sym overwrite the old one:

In[3]:=
ResourceFunction["EchoSet"][x, 3]
Out[3]=

Make indexed assignments:

In[4]:=
ResourceFunction["EchoSet"][g[1], 4]; g[1] + 1
Out[4]=

In EchoSet[sym,value], value is evaluated:

In[5]:=
ResourceFunction["EchoSet"][y, Expand[(x + 1)^5]]
Out[5]=

Possible Issues (1) 

EchoSet does not thread over lists:

In[6]:=
ResourceFunction["EchoSet"][{x, y, z} = Range[3]]
Out[6]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 14 January 2019

License Information