[ENH] String repeat

Andrew P. Black black at cse.ogi.edu
Mon May 29 07:32:29 UTC 2000


At 8:54 +0200 2000.5.29, Bert Freudenberg wrote:

>2. It should have a more descriptive selector (at least repeat:).

It seems to me that the multiplication symbol, *, is the most 
descriptive selector.

  	'aa' * 4 => 'aaaaaaaa'

Unfortunately, someone already decided that it would be a good idea 
to do automatic conversions from strings to numbers, so * is already 
"taken"

	'25' * 4 => 100

If I had my druthers, I would reserve * on strings for repetition, 
and require the use of the #asNumber String to Number conversion if 
that is what is required.

Also, as has already bee pointed out, * for repetition is generic to 
ordered collections, whereas * meaning convert to Number and then 
multiply is specific to Strings.

			Andrew





More information about the Squeak-dev mailing list