From: Charles Oliver Nutter Date: 2008-12-19T10:26:53+09:00 Subject: [ruby-core:20675] Re: [Feature #905] Add String.new(fixnum) to preallocate large buffer Brian Ford wrote: > Issue #905 has been updated by Brian Ford. > > > In Rubinius, we have found it useful to have String.pattern(size, value) where value can be a fixnum or a string. The string created will be size characters where value is repeated. For example: > > String.pattern(5, ?a) # => "aaaaa" > String.pattern(5, " ") # => " " > String.pattern(5, "110") # => "11011" > > Something like "ab" * 5 then becomes String.pattern("ab".size * 5, "ab"). Yeah, seems like a reasonably good idea. The string formats seem a little weird to me though...not what I'd expect. The analog with an array would be to accept another array as the fill value, which seems equally weird.