<div dir="ltr"><div>Hi,</div><div>Ah yes, it works, no need for extra [] value<br></div><div><br></div><div> (3 > 2) ifTrue: [Transcript cr; show: 'bingo!']; yourself</div><div><br></div><div>The code is not optimized, but it works.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le jeu. 16 mai 2019 à 16:52, Torge Husfeldt <<a href="mailto:torge.husfeldt@gmx.de">torge.husfeldt@gmx.de</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
<p>Salut Nico,</p>
<p>please excuse if my squeak knowlege is a bit rusty, but wouldn't
this do the job:</p>
<p>self findlast: [:each |<br>
</p>
<p>[self testSomeConditionFor: each] value ifTrue:[self
performSomeAction:each]; yourself.</p>
<p>].</p>
<p>Just an idea. And very sad that I have to wrap the condition in a
block, but I guess othewise the recipient for "yourself" would be
"self"<br>
</p>
<div class="gmail-m_-6434532090840975697moz-cite-prefix">On 14.05.19 17:02, Nicolas Cellier
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>Oups, my example was a bit stupid because findLast: loop
stops at first true, but you get my intention...</div>
<div>Replace with select:/reject: or provide a whenFalse: side
effect...<br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">Le mar. 14 mai 2019 à 16:23,
Nicolas Cellier <<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>>
a écrit :<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div>Hi,</div>
<div>From time to time, I need to perform some additional
action (side effect) when a boolean is true, but preserve
that boolean as return value.</div>
<div><br>
</div>
<div>Here is a pseudo example:<br>
</div>
<div><br>
</div>
<div> self findLast: [:each |</div>
<div> | conforming |<br>
</div>
<div> conforming := self testSomeConditionFor: each.</div>
<div> conforming <br>
</div>
<div> ifTrue:</div>
<div> [ "found one, do some side effect
before searching next" <br>
</div>
<div> self performSomeAction: each ].<br>
</div>
<div> conforming ].</div>
<div><br>
</div>
<div>Or shorter, but I dislike the redundant true:
<div><br>
</div>
<div> self findLast: [:each |</div>
<div> (self testSomeConditionFor: each)</div>
<div> and:</div>
<div> [ "found one, do some side effect
before searching next" <br>
</div>
<div> self performSomeAction: each.</div>
<div> true ]].</div>
<div><br>
</div>
<div>What i seek is even shorter:
<div><br>
</div>
<div> self findLast: [:each |</div>
<div> (self testSomeConditionFor: each)</div>
<div> whenTrue:</div>
<div> [ "found one, do some side effect
before searching next" <br>
</div>
<div> self performSomeAction: each ]].</div>
<div><br>
</div>
<div>Of course, we would have companions whenFalse:,
whenTrue:whenFalse:...<br>
</div>
<div>Would you buy it?<br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
<fieldset class="gmail-m_-6434532090840975697mimeAttachmentHeader"></fieldset>
</blockquote>
</div>
<br>
</blockquote></div>