Comment by antonvs
20 days ago
> scream for a case/switch-statement
Maybe I’m missing some context, but all that actually should be needed in the top-level else block is ‘gradient[idx]’. Pretty much anything else is going to be longer, harder to read, and less efficient.
True, with early return - there's no need to actually nest with else.
Logically this still would be a case/switch though...
The point was that logically it would be an array lookup by index.
There's no need for any conditional construct here whatsoever.
You'll note it has already constructed a string in the right order to do that, but then copped out with the if-else.
True enough. On that note, I had a look at the language reference - there's arrays - but also this:
So, you can pluck a character... From an UTF-8 string? What if the rendering used multibyte characters?
4 replies →