I have a method like that:
===
public string repeat(string s, int num)
{
string result = s;
for (int i=1; inum; i++)
result ~= s;
return result;
}
===
basically it will create num string, each a little longer...
is there a more efficient way to go about that?
thanks! :)
On Sun, 12 Jun 2011 12:49:25 -0400, Lloyd Dupont ld-rem...@galador.net
wrote:
I have a method like that:
===
public string repeat(string s, int num)
{
string result = s;
for (int i=1; inum; i++)
result ~= s;
return result;
}
===
basically it will create num string, each a
On 2011-06-12 11:08, Steven Schveighoffer wrote:
On Sun, 12 Jun 2011 12:49:25 -0400, Lloyd Dupont ld-rem...@galador.net
wrote:
I have a method like that:
===
public string repeat(string s, int num)
{
string result = s;
for (int i=1; inum; i++)
result ~=
But... string being immutable I don't see the point of allocating some space
for one..
Am I missing something?
Steven Schveighoffer wrote in message
news:op.vwy503w4eav7ka@localhost.localdomain...
On Sun, 12 Jun 2011 12:49:25 -0400, Lloyd Dupont ld-rem...@galador.net
wrote:
I have a
Thanks!
Jonathan M Davis wrote in message
news:mailman.851.1307909610.14074.digitalmars-d-
Also, std.string.repeat has been scheduled for deprecation. You should use
std.array.replicate instead. It does the same thing but for all arrays
instead
of just strings.
- Jonathan M Davis
On 2011-06-12 18:02, Lloyd Dupont wrote:
But... string being immutable I don't see the point of allocating some
space for one..
Am I missing something?
Just because it's immutable doesn't mean that it doesn't need to exist at
runtime. All immutable means is that you can't change it. It could
On Sun, 12 Jun 2011 21:02:05 -0400, Lloyd Dupont ld-rem...@galador.net
wrote:
But... string being immutable I don't see the point of allocating some
space for one..
Am I missing something?
Reserving space for appending does not make that space immutable, yet.
As far as the runtime is
Thanks Steven, that was very informative!
Steven Schveighoffer wrote in message
news:op.vwzrwdmteav7ka@localhost.localdomain...
On Sun, 12 Jun 2011 21:02:05 -0400, Lloyd Dupont ld-rem...@galador.net
wrote:
But... string being immutable I don't see the point of allocating some
space for