tests/pass/gmatch.lua

changeset 126
07ec490c7a6f
equal deleted inserted replaced
125:39b6ba804009 126:07ec490c7a6f
1 local i = 1;
2 local s = "the rain in spain stays mainly in the plain";
3 local st = { "the", "rain", "in", "spain", "stays", "mainly", "in", "the", "plain" };
4 for word in string.gmatch(s, "%a+") do
5 print(word)
6 assert(word == st[i], word.." == "..st[i]);
7 i = i + 1;
8 end
9
10 assert(i == 10, i.." == 10");

mercurial