<html><head></head><body><div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1510980376203_21659">nil is the sole instance of UndefinedObject.</div><div id="yui_3_16_0_ym19_1_1510980376203_21710"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1510980376203_21711">It's the value assigned by default to every object (more or less but we'll get there when you'll get the basics) when they are created.  In your case, when you execute/inspect the very last line of your workspace, a is uninitialized, hence nil.</div><div dir="ltr" id="yui_3_16_0_ym19_1_1510980376203_21738"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1510980376203_21830">You must not see the whole workspace as a "program".  The environment, in a workspace, execute/prints/inspects just what you  *select* and executes/prints/inspects ONLY that! The workspace doesn't care what you executed before!  All it cares about evaluating is the portion of code that you highlight.<br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1510980376203_21713"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1510980376203_21728">----------------- <br></div><div class="signature" id="yui_3_16_0_ym19_1_1510980376203_21604">BenoĆ®t St-Jean <br>Yahoo! Messenger: bstjean
 <br>Twitter: @BenLeChialeux
 <br>Pinterest: benoitstjean
 <br>Instagram: Chef_Benito<br>IRC: lamneth
 <br>Blogue: endormitoire.wordpress.com
 <br>"A standpoint is an intellectual horizon of radius zero".  (A. Einstein)</div><div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" style="display: block;">  <div style="font-family: Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1"> <b><span style="font-weight:bold;">From:</span></b> RedTigerFish <chihuyu@gmail.com><br> <b><span style="font-weight: bold;">To:</span></b> beginners@lists.squeakfoundation.org <br> <b><span style="font-weight: bold;">Sent:</span></b> Saturday, November 18, 2017 2:36 AM<br> <b><span style="font-weight: bold;">Subject:</span></b> [Newbies] Why the variable "a" is different out of the loop when codes are executed as a whole or by two steps?<br> </font> </div> <div class="y_msg_container"><br><div dir="ltr"><br></div><div dir="ltr"><br></div><div dir="ltr"><br></div><div dir="ltr"><br></div><div dir="ltr">Hello, friends. <br></div><div dir="ltr"><br></div><div dir="ltr">This problem which confuses me comes from a  question<br></div><div dir="ltr"><<a href="http://forum.world.st/quot-Print-specific-integers-quot-Error-message-how-to-improve-and-what-causes-that-td5025067.html" target="_blank">http://forum.world.st/quot-Print-specific-integers-quot-Error-message-how-to-improve-and-what-causes-that-td5025067.html</a>> <br></div><div dir="ltr">I asked in "Squeak - Beginners" days ago.  <br></div><div dir="ltr"><br></div><div dir="ltr">These are some special integers: myArray := #(2 32 44 67 89 111 123)<br></div><div dir="ltr">These special integers need to be specially labelled from integer 1 to 130. <br></div><div dir="ltr">The rest normal numbers which myArray doesn't include will be printed also. <br></div><div dir="ltr"><br></div><div dir="ltr">Here's the code:<br></div><div dir="ltr"><br></div><div dir="ltr">*|a n myArray| <br></div><div dir="ltr"><br></div><div dir="ltr">myArray := #(2 32 44 67 89 111 123). <br></div><div dir="ltr"><br></div><div dir="ltr">n := 1. <br></div><div dir="ltr">a := myArray at: n. <br></div><div dir="ltr"><br></div><div dir="ltr">1 to: 130 do: [:i| <br></div><div dir="ltr">        i = a <br></div><div dir="ltr">        ifTrue: [ <br></div><div dir="ltr">             Transcript show: ('Special number:  i = {1}, a = {2}' format:<br></div><div dir="ltr">{i. a}).<br></div><div dir="ltr">         Transcript cr.<br></div><div dir="ltr">                n := n + 1.      <br></div><div dir="ltr">            n = 8 <br></div><div dir="ltr">           ifTrue: [a := 'I am no longer a number'.]<br></div><div dir="ltr">           ifFalse: [a := myArray at: n. ].      <br></div><div dir="ltr">                ]<br></div><div dir="ltr">      ifFalse: [<br></div><div dir="ltr">               Transcript show: ('i = {1}, a = {2}' format: {i. a}).<br></div><div dir="ltr">               Transcript  cr.<br></div><div dir="ltr">              ].<br></div><div dir="ltr">        ]. <br></div><div dir="ltr"><br></div><div dir="ltr"><br></div><div dir="ltr">Transcript show: a; cr.     'Last line'<br></div><div dir="ltr">*<br></div><div dir="ltr"><br></div><div dir="ltr">Now comes something that makes my head big.<br></div><div dir="ltr"><br></div><div dir="ltr">If I choose everything and do them, the last line, which should tell me what<br></div><div dir="ltr">a is when program jumps out of the loop, exactly shows that a is "I am no<br></div><div dir="ltr">longer a number".<br></div><div dir="ltr"><br></div><div dir="ltr">However, if I choose everything except the last line, and do them. After<br></div><div dir="ltr">that, I do the last line. The output is nil. <br></div><div dir="ltr"><br></div><div dir="ltr">Why is a nil ?   Why's that?   <br></div><div dir="ltr"><br></div><div dir="ltr">In order to make my question explicit, I recorded a video:<br></div><div dir="ltr"><br></div><div dir="ltr"><a href="https://www.youtube.com/watch?v=pUQAEO4uSpk" target="_blank">https://www.youtube.com/watch?v=pUQAEO4uSpk</a><br></div><div dir="ltr"><br></div><div dir="ltr"><br></div><div dir="ltr"><br></div><div dir="ltr">-----<br></div><div dir="ltr">Dig, dig where you are,<br></div><div dir="ltr">Down below's well.<br></div><div dir="ltr">Let those that walk in darkness shout, <br></div><div dir="ltr">Down below's hell.<br></div><div dir="ltr">--<br></div><div dir="ltr">Sent from: <a href="http://forum.world.st/Squeak-Beginners-f107673.html" target="_blank">http://forum.world.st/Squeak-Beginners-f107673.html</a><br></div><div dir="ltr">_______________________________________________<br></div><div dir="ltr">Beginners mailing list<br></div><div dir="ltr"><a ymailto="mailto:Beginners@lists.squeakfoundation.org" href="mailto:Beginners@lists.squeakfoundation.org">Beginners@lists.squeakfoundation.org</a><br></div><div dir="ltr"><a href="http://lists.squeakfoundation.org/mailman/listinfo/beginners" target="_blank">http://lists.squeakfoundation.org/mailman/listinfo/beginners</a><br></div><br><br></div> </div> </div>  </div></div></body></html>