<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" 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="moz-cite-prefix">On 14.05.19 17:02, Nicolas Cellier
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAKnRiT6DRXbLxGrxBKSFKvrqJKNJVHP-1Vk3rf9bmbOUVOUrpQ@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <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"
            moz-do-not-send="true">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="mimeAttachmentHeader"></fieldset>
    </blockquote>
  </body>
</html>