digitalmars.D.learn - 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'?
Sep 02 2014
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.
Sep 02 2014