0

I have to declare about 300 constants and was wondering if there is any faster, better way than to write each one out individually.

    const CHANNEL1              = "G";
    const CHANNEL2              = "U";
    const CHANNEL3              = "E";
    const CHANNEL4              = "I";

ETC.. all the way to const CHANNEL300

Dave Gray
  • 1
  • 1
  • 1
    Write a script that does it for you. Of course, that may take equally as long.... – John Conde Aug 27 '14 at 19:19
  • @JohnConde Or, longer! ;) – Andrew Barber Aug 27 '14 at 19:21
  • 4
    Having lots of variables or constants with numeric suffixes usually indicates poor design. They should be an array. And if it's a bunch of characters, maybe it should be a single string, which you access by position. – Barmar Aug 27 '14 at 19:22
  • Where do all these constants come from, maybe it should be a function that calculates them. – Barmar Aug 27 '14 at 19:23
  • its just a temporary fix until we make it dynamic. Scope would be to large for this release and this is just a quick fix for the meantime – Dave Gray Aug 27 '14 at 21:23
  • what is the relationship between the constant name and the value. What would be next in the series? – Len_D Aug 27 '14 at 22:24
  • also these are class constants, I dont think you can create a function that will make these as they are hard coded – Dave Gray Aug 27 '14 at 23:03
  • The constants are for 2 channels , I need 100 facebook ad and 100 google ad constants. – Dave Gray Aug 27 '14 at 23:05

0 Answers0