4 ms·
I can't give any really strong justification, besides to say that C-style constants make me feel warm and safe. My weak justifications are that I find having my
by mistercow 15y ago
I can't give any really strong justification, besides to say that C-style constants make me feel warm and safe. My weak justifications are that I find having my constants declared in one place helps me to remember to handle all of them, and that it helps slightly with auto-complete.
But there is a good reason in the case of the cubicTension constants: those aren't enums, but actual values. You can put any cubicTension parameter you want between 0 and 1.
- Cushman 15y agoTotally get that-- if it's the style you're comfortable with, go for it. Hope I didn't sound critical, just curious. Although if I may, there is a potential benefit to using strings there in that it lets you get rid of the switch statement entirely: unless config.clip of ClipHelpers throw new Error "No clip mode '#{config.clip}'. Available modes are #{(k for k of ClipHelpers).join(', ')}" clipHelper = ClipHelpers[config.clip] This could also make it easy for a user to add helpers at runtime. Maybe overkill for this, just something to keep in mind.