September 03, 2014 Question about 'this' | ||||
---|---|---|---|---|
| ||||
string getString2(in string input) { long start, end; while(start < input.length && input[start] != '"') start++; start++; end = input.length - 1; while(end > 0 && input[end] != '"') end--; end--; return input[start .. end]; } unittest { (543) writeln(getString2(`st"1 2 3"`)); } control.d(543): Error: 'this' is only defined in non-static member functions, not __unittestL542_3 What does it mean about 'this'? |
September 03, 2014 Re: Question about 'this' | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joel | On Wednesday, 3 September 2014 at 04:00:30 UTC, Joel wrote:
> string getString2(in string input) {
> long start, end;
> while(start < input.length && input[start] != '"')
> start++;
> start++;
> end = input.length - 1;
> while(end > 0 && input[end] != '"')
> end--;
> end--;
>
> return input[start .. end];
> }
>
> unittest {
> (543) writeln(getString2(`st"1 2 3"`));
> }
>
> control.d(543): Error: 'this' is only defined in non-static member functions, not __unittestL542_3
>
> What does it mean about 'this'?
Oh, I get it now. It's in a struct scope.
|
Copyright © 1999-2021 by the D Language Foundation