Skip to content

Instantly share code, notes, and snippets.

@Samathy
Created February 28, 2016 18:48
Show Gist options
  • Save Samathy/a4f9338f3875f14f637c to your computer and use it in GitHub Desktop.
Save Samathy/a4f9338f3875f14f637c to your computer and use it in GitHub Desktop.
One change in character completly changes the behaviour of this.
import std.string;
import std.stdio;
void main()
{
string s ="string";
string[4] c = ['a','g','t','s'];
string[4] d = ["a","g","t","s"];
for (int i = 0; i < c.length; i++)
{
writeln(c[i]); //always prints 'agts'
writeln(indexOf(s, c[i])); //Always is -1
}
for (int i = 0; i < d.length; i++)
{
writeln(d[i]); //always prints EITHER 'a','g','t' or 's'
writeln(indexOf(s, d[i]));
}
writeln(c);
// prints:
// ["agts", "agts", "agts", "agts"]
writeln(d);
//prints
// ["a","g","t","s"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment