Uploaded image for project: 'Commons JEXL'
  1. Commons JEXL
  2. JEXL-262

Inline object property initialization construct

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Won't Do
    • 3.1
    • 3.1
    • None

    Description

      I wonder is it possible (not difficult) to implement in Jexl a construct that would allow us to initialize object properties in one statement, so that it would be possible to replace the code like

      var i = Address;
      i.City = 'NY';
      i.Street = '1st Avenue';
      i.House = '22';
      return i;
      

      with something like

      Address {City : 'NY', Street : '1st Avenue', House : '22'}
      

      May be we could also consider a variant for array-style accessors, like

      var i = Address;
      i["City"] = 'NY';
      i["Street"] = '1st Avenue';
      i["House"] = '22';
      return i
      

      would be identical to

      Address {"City" : 'NY', "Street" : '1st Avenue', "House" : '22'}
      

      I think this is somewhat similar to inline map initialization syntax, which is proved to be very useful and productive, so it would be nice to have such a feature for common objects too

      Attachments

        Activity

          People

            henrib Henri Biestro
            dmitri_blinov Dmitri Blinov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: