3 ms·
Not all arrays can be summed, but they all claim to respond to #sum. This is extremely broken. This is how I felt when I first saw Array#sum. But then I took a
by davidmathers 18y ago
Not all arrays can be summed, but they all claim to respond to #sum. This is extremely broken.
This is how I felt when I first saw Array#sum. But then I took a few hi-
But then I tried it a few times. And now I can quit anytime I want.
I think String#titlecase is correct though. Not all arrays can be summed, but all strings can be titlecased, including part codes.
- randallsquared 18y agoBut does String#titlecase do the right thing for ß? :)
- jeffesp 18y agoBut the point isn't that String#titlecase can't do the right thing here. I assume there is an implementation of titlecase that will work with ß. But I can't think of an Array#sum that will work for [1, "two"]. Of course your :) might have meant you were being funny, then I just totally missed your point and explained something you already know.
- randallsquared 18y agoWell, there is a tenuous connection in that it's not obvious what to do for casing of ß. I wrote some unicode stuff for CL once and figuring this out was a nightmare. In any case, if you have two data types that that don't make any other sense as an addition, you could always just convert them both to bitfields and sum that... now I'm just being silly. Don't mind me.
- davidmathers 18y agoAccording to wikipedia "ß".upcase is "SS", except in the case of legal documents it remains "ß". I checked irb and "ß".upcase is "ß", so I guess strings in ruby are of type "german legal document." I also just learned that the reason there's no uppercase ß is that no words start with ß, so titlecase would never touch it.