Help: StringToEnum or StringToTimeframe - page 2

 
Dave Bieleveld #:

That’s not my code, I don’t use input = ‘m1’

but if you’re referring to OP, your proposal does make the code arbitrarily/arguably more readable, in return for using switch and limiting the amount of chars. Either way, you have to validate incoming data from the api anyway, so I’m not inclined to make unnecessary castings and conversions. And I guess we’d have to cast the timeframe constants in the “case” also to long, possibly making it even more complex.

unless there is a compelling performance or integrity benefit, the added complexity makes the readability less intuitive, and verbose imho. But it’s matter of style i guess.

For instance, I agree i personally prefer the switch too for translations, however it’s a pity mql does not support strings with it.

Its an old post anyways.