[Vala] Switch statement and substring
- From: Харин Роман <HarinRoman kranky-studio ru>
- To: vala-list gnome org
- Subject: [Vala] Switch statement and substring
- Date: Tue, 30 Jun 2009 10:17:01 +0400
Hi, all
There are something strange with string function "substring" in switch
statement. Second switch works fine, but first not. why? (const char* ?)
I write testcase.
--
Харин Роман <HarinRoman kranky-studio ru>
jabber://harinr jabber ru
монопофигист
/* valac test_switch.vala -o test_switch */
void test_switch (string input) {
var st2 = input.substring (1,1);
stdout.printf ("Input: \"%s\", substr: \"%s\",", input, st2);
stdout.printf (" substr: ");
/* THIS SWITCH WORKS INCORECTLY */
switch (input.substring (1,1)) {
case "a":
stdout.printf ("A"); break;
case "b":
stdout.printf ("B"); break;
default:
stdout.printf ("*"); break;
}
stdout.printf (", var: ");
/* THIS SWITCH WORKS FINE */
switch (st2) {
case "a":
stdout.printf ("A\n"); break;
case "b":
stdout.printf ("B\n"); break;
default:
stdout.printf ("*\n"); break;
}
}
void main () {
test_switch ("1a");
test_switch ("2b");
test_switch ("3c");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]