Find a char among string (string.findAmong.char)
BoQsc
vaidas.boqsc at gmail.com
Wed Jul 7 12:22:11 UTC 2021
I think nested foreach loops are more readable.
```
import std;
void main()
{
alias alphabet = letters;
char[26] letters = ['a','b', 'c', 'd', 'e',
'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z'];
string wordExample = "Book.";
foreach (letter; wordExample){
foreach (alphabetLetter; letters){
if (letter == alphabetLetter) {
writeln(letter);
}
}
}
}
```
More information about the Digitalmars-d-learn
mailing list