Strange behavior std.range.takeNone

Dennis Ritchie via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Apr 6 19:52:24 PDT 2015


On Tuesday, 7 April 2015 at 02:24:00 UTC, Dennis Ritchie wrote:
> Is it OK?
Although, perhaps, everything is fine. I just thought that 
creates takeNone not string type string, and the string array of 
type string[].

import std.stdio : writeln;

void main() {

	string s;

	s ~= 5;

	writeln(s); // prints ♣
}

So I mixed up with this case. Everything is OK.

import std.range : takeNone;

void main() {
	
	auto s = takeNone(["test"]);
	
	// s ~= 5; // Error: cannot append type int to type string[]
}


More information about the Digitalmars-d-learn mailing list