Uploaded image for project: 'Railo'
  1. Railo
  2. RAILO-2887

arrayEach() should pass the array index into the callback

    XMLWordPrintable

    Details

    • Type: Feature Request
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 4.2.0.001
    • Fix Version/s: None
    • Labels:
      None

      Description

      If I want to know which index each element is at, I need to infer that myself (ie: with the i variable that I maintain "by hand") . arrayEach() would be a lot more fully-realised if its callback was also passed the index. I think that a very high percentage of the time, one would want to know which element one is looking at, as well as the element value. It's a bit "jerry-built" to have to roll one's own.

      <cfscript>
      a = ["Tahi","Rua","Toru","Wha","Rima","Ono","Whitu","Waru","Iwa","Tekau"];
      
      arrayEach(
      a,
      function(element){
      param name="i" default=1;
      writeOutput("#i++# #uCase(element)#<br />");
      }
      );
      </cfscript>
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                micstriit Michael Offner
                Reporter:
                adamcameroncf Adam Cameron
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: