<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000">
                                        
                                        
                                            
                                        
                                        
                                        Hi Karl.<div><br></div><div>The issue is that, in your example, you are always using the same instance of Array: </div><div><br></div><div><div>initialize</div><div><span style="white-space:pre">        </span>super initialize.</div><div><span style="white-space:pre">     </span>grid := Matrix rows: 3 columns: 3 contents: #(</div><div><span style="white-space:pre">        </span>5 3 0 </div><div><span style="white-space:pre">   </span>6 0 0 </div><div><span style="white-space:pre">   </span>0 9 8 )</div></div><div><br></div><div>Those "contents" will always be the same for each new instance of TesterClass. So, even though the source code reads "#( 5 3 0 ..." is has actually changed to "#( 9 9 9 ...". Try inspecting "TesterClass >> #initalize" and take a look at #literal5:</div><div><br></div><div><img id="e1975963-279e-4ff0-b8ba-4715a61a7d84" src="cid:31020277-e79b-4bb0-ba0a-f1540fb09ff2" width="auto"></img><br></div><div><br></div><div>This is not a bug. :-) Just a (maybe surprising) side effect of literal arrays.</div><div><br></div><div>Best,</div><div>Marcel</div><div class="mb_sig"></div>
                                        
                                        <blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px">
                        <p style="color: #AAAAAA; margin-top: 10px;">Am 19.02.2020 09:09:03 schrieb karl ramberg <karlramberg@gmail.com>:</p><div style="font-family:Arial,Helvetica,sans-serif">
<div dir="ltr"><div>Hi,</div><div>I have this simple class TesterClass new. <br></div><div>Doit  in Workspace: TesterClass inspect.</div><div>The grid instance variable is initialized according to initialize method.<br></div><div>I doit in inspector: self fillGrid.<br></div><div>The grid matrix is now filled with all 9.</div><div>As expected.<br></div><div><br></div><div> Now doit in Workspace: TesterClass new inspect<br></div><div>The grid is all 9.</div><div><br></div><div>I think the issue is in <br></div><div>Matrix class>>rows: columns: contents: <br></div><div>rows: rows columns: columns contents: contents<br>        ^super new rows: rows columns: columns contents: contents</div><div><br></div><div>Matrix class overrides new so I think there is a conflict <br></div><div><br></div><div>Best,</div><div>Karl <br></div><div><br></div><div><br></div><div><br></div><br><div><br></div><div>'From Squeak5.3alpha of 23 October 2019 [latest update: #19139] on 18 February 2020 at 9:22:56 pm'!<br>Object subclass: #TesterClass<br>       instanceVariableNames: 'grid'<br> classVariableNames: ''<br>        poolDictionaries: ''<br>  category: 'MyTestStuff'!<br><br>!TesterClass methodsFor: 'as yet unclassified' stamp: 'kfr 2/18/2020 21:21'!<br>fillGrid<br>    grid atAllPut: 9! !<br><br>!TesterClass methodsFor: 'as yet unclassified' stamp: 'kfr 2/18/2020 21:18'!<br>initialize<br>       super initialize.<br>     grid := Matrix rows: 3 columns: 3 contents: #(<br>        5 3 0 <br>        6 0 0 <br>        0 9 8 )! !<br></div></div>
</div></blockquote></div>