From: Leslie Viljoen Date: 2006-06-15T17:08:41+09:00 Subject: Re: A plan for another unicode string hack On 6/15/06, Joel VanderWerf wrote: > Dave Howell wrote: > > > > On Jun 14, 2006, at 9:17, Austin Ziegler wrote: > > > > Yes, I undertstand. Making #size and #length return different values > > is a mistake. Without referring to documentation, how would you know > > which returns the number of characters and which one returns the > > number of bytes? > > > > I cannot agree. "Length" (to me) unavoidably implies that it's the > > answer to the question "How LONG is it?" I expect the answer to be "n > > characters long." > > > > "Size" is the answer to "How BIG is it?" as in "How much space does this > > thing take up?" and if it's a UTF-8 string, I expect an answer like "1 > > byte per character + one more byte per character not in the 7-bit ASCII > > range" > > That's not a bad argument, but Hash#size and Array#size don't behave > that way in ruby. I agree with Austin on this - the distinction is too vague. I'd leave length and size the same and make a size_in_bytes method. Les