A new class -->String

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Wed Apr 4 02:52:37 PDT 2007


jinheking wrote:
> String opAssign(wchar[] value) {
>    int size = value.length;
>    offset = 0;
>    count = size;
>    value = value;
>    return this;
>     }
> 
> That is this funcation!

I'm sorry, I don't understand what you're trying to say.

If you were confused about my comment on that function in particular, 
let me try to reword it:
The way I would code that function (assuming the class fields stay the 
same) would be like so:
---
String opAssign(wchar[] value) {
     offset = 0;
     count = value.length;
     this.value = value.dup;
     return this;
}
---
The 'this.' makes sure it assigns to the 'value' defined at the top of 
the class, not the one parameter.
The '.dup' makes a copy of the string passed in to make sure nobody else 
can change the value of the String object, since you want it to be 
immutable.



More information about the Digitalmars-d mailing list