[Vala] request to add another example to Projects/Vala/ListExample
- From: MohanR <mohan43u gmail com>
- To: vala <vala-list gnome org>
- Subject: [Vala] request to add another example to Projects/Vala/ListExample
- Date: Sat, 19 Mar 2016 00:56:19 +0530
Hi,
I'm a beginner in vala. I would like to add the following example to
this wiki link to make other beginners understand important thing about
List<string>.
https://wiki.gnome.org/Projects/Vala/ListSample
int main(string[] args) {
List<string> mylist = new List<string>();
mylist.append("hi");
mylist.append("how");
mylist.append("are");
mylist.append("you");
/* prints length: 4 */
stdout.printf("length: %u\n", mylist.length());
/* following wont work as expected because in
* C universe, "how" and "how" is not equal
*/
mylist.remove("how");
/* still prints length: 4 */
stdout.printf("length: %u\n", mylist.length());
/* works because "how" and "how" is equal
* according to strcmp()
*/
mylist.remove_link(mylist.find_custom("how", strcmp));
/* prints length: 3 */
stdout.printf("length: %u\n", mylist.length());
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]