From: Jim Weirich Date: 2008-12-19T20:56:43+09:00 Subject: [ruby-core:20697] Re: [Feature #905] Add String.new(fixnum) to preallocate large buffer On Dec 18, 2008, at 8:04 PM, Charles Oliver Nutter wrote: > Yukihiro Matsumoto wrote: >> I like the idea. >> But I'd prefer adding a new class methodfor the purpose, >> say. String#buffer(n), to adding new role to an argument by type, >> or there may be a better name. > > I thought String.new(1000) would be a nice equivalent to > Array.new(1000), since they both do essentially the same thing. There is a slight difference. Array.new(1000) creates an array with a thousand elements. The proposed String.new(1000) would create a string with zero characters, but the ability to grow to 1000 characters (umm, bytes) without internal reallocation. I think this difference is enough to warrant different names. -- -- Jim Weirich -- jim.weirich@gmail.com