<div>Hi all,</div><div>I&#39;m refactoring my code and I found that I have two ways to do the same in distint parts of my system.</div><div><br></div><div>1) Entity class &gt;&gt; atCode: aCode</div><div>&quot;Answer the receiver instance with code equal to aCode or evaluate aBlock if it doesn&#39;t exists.&quot;</div>
<div><br></div><div>       ^(self all detect: [:one | one code = aCode]) copy</div><div><br></div><div>or</div><div><br></div><div><div>2) Entity class&gt;&gt; atCode: aCode inSession: anUserSession</div><div>&quot;Answer the receiver instance with code equal to aCode or evaluate aBlock if it doesn&#39;t exists.&quot;</div>
</div><div> </div><div>       ^(self allInSession: anUserSession) detect: [:one | one code = aCode]</div><div><br></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif">The difference is that 1 is using the shared session so I need copy the object to be used (referenced by other object) on anUserSession. The uggly of 2 is that I have to pass anUserSession as argument. </font></div>
<div><font class="Apple-style-span" face="arial, helvetica, sans-serif">Either way works well, is really the same?</font></div><div><br></div><div>Thanks in advance,</div><div>Facu</div><div><br></div><div>(*) I eliminate aBlock for absent elements for this example</div>