News for hackers. Stuff that matters.
Re:My Objection to Array#sum by davidmathers on Thursday April 09, 2009 @01:44PM (#554772)
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.

Re:My Objection to Array#sum by randallsquared on Thursday April 09, 2009 @01:54PM (#554790)
But does String#titlecase do the right thing for ß? :)
Re:My Objection to Array#sum by jeffesp on Thursday April 09, 2009 @02:31PM (#554883)
But 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.

Re:My Objection to Array#sum by randallsquared on Thursday April 09, 2009 @05:46PM (#555225)
Well, 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.
Re:My Objection to Array#sum by davidmathers on Thursday April 09, 2009 @06:18PM (#555272)
According 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.