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

Cannot default first argument in reduce()'s callback

    Details

    • Type: Enhancement
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Out of Date
    • Affects Version/s: 4.2.1.003
    • Fix Version/s: None
    • Labels:
      None

      Description

      This should work:

      rainbow	= ["Whero","Karaka","Kowhai","Kakariki","Kikorangi","Tawatawa","Mawhero"];
      asString = rainbow.reduce(function(reduction="", colour){
      	reduction &= colour;
      	return reduction;
      });
      writeDump([rainbow,asString]);
      

      Note how I am defaulting the reduction argument, instead of passing an empty string to reduce() as a starting value. Both approaches are valid (and supported in CF11).

      However it errors with:

      variable [REDUCTION] doesn't exist
      

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: