Benji Weber wrote:
Hi all, ... Therefore I would expect the following programme to print "One" "Two" "Three". However, it actually prints "One" "One" "Three".
string Two() { string value = "One"; foreach(string str, ["Two"], { return str; }); return value; }
"return" in "foreach" means that the interpreter skips to another loop of the "foreach", eventually finishes the "foreach" if it is the last one. You might want to modify your code this way :) --- cut --- string Two() { string value = "One"; foreach(string str, ["Two"], { value = str; }); return value; } --- cut --- http://forgeftp.novell.com/yast/doc/SL10.2/tdg/YCPBuiltinList_foreach.html According to the link mentioned above, "return" in "foreach" should return the last value value from "foreach". --- cut --- integer aaa_foreach = foreach (integer v, [1,2,3], { return v + 10; }); Then: aaa_foreach == 13 --- cut --- Lukas -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org