5 ms·
> Minor new features[...] String padding well, that's certainly one way to avoid another `leftPad` mess :)
by riffraff 10y ago
> Minor new features[...] String padding
well, that's certainly one way to avoid another `leftPad` mess :)
- rootlocus 10y agoCatastrophe driven language design?
- deathanatos 10y ago… does it work at a level higher than code units? From what I recall, leftpad's implementation worked at the level of code units, i.e., it padded to a particular number of code units, which is bugged for just about any use case one might apply it to. That is, if you had the strings "a" and "é" (where the latter is "e\u0301") padded "equally" to length 3, leftpad would pad them approximately thusly: __a _é > leftpad('e\u0301', 3, '_'); <- "_é"
- ygra 10y agoI very much doubt it. If it did, they would have to use grapheme clusters as measurement which nearly no one does. The easier way out is to just say »we have a trivial implementation that can only be used on strings where the developer already knows what's in it«.
- petetnt 10y agoThe string padding proposal predates the `leftPad` debacle by a year though. Ponyfills (like `leftPad`) will be needed for years to come due to the nature of web browsers.