Re: Variables within With statement
- To: mathgroup at smc.vnet.net
- Subject: [mg123747] Re: Variables within With statement
- From: Shizu <slivo.vitz at msa.hinet.net>
- Date: Sat, 17 Dec 2011 02:45:08 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
In Block[], global variables have local values.
So, this will work:
Clear[a];
Block[{a = 5, b = 10 a}, a + b]
In With[], rhs of an assignment(eg., 10 a) is evaluated before With[] as a whole.
So, b = 10 a, and a's value is global.
And so, this doesn't work for your case:
Clear[a];
With[{a = 5, b = 10 a}, a + b]