3 ms·
Shouldn't the uppercase of a number be a string? const makeUpperCase = t.pattern( (input: string) => input.toUpperCase(), (input: number) => ''
by koolba 9y ago
Shouldn't the uppercase of a number be a string?
const makeUpperCase = t.pattern(
(input: string) => input.toUpperCase(),
(input: number) => '' + input
);
Otherwise you get odd behaviours like:
makeUpperCase('1') + makeUpperCase('1') = '11' (probably what you want)
makeUpperCase(1) + makeUpperCase(1) = 2 (probably not what you want)
- phpnode 9y agoYeah probably, but it's just an example
- rezistik 9y ago...wait. Why would the uppercase of '1' be '11'? It would just be '1'.
- livingparadox 9y agoI had to reread it a few times to parse it. Its result of "adding" the uppercase of 1 that should be 11, not the uppercase itself. In other words, the result of "makeUppercase" should be a string, not a number.
- rezistik 9y agoI see it now.