Hi,
thanks a lot for your contribution. The wiki is open, you can register and
edit it freely! :)

Also pay attention to the comment about "how" and "how". In C, they are
equivalent because those are const strings and have the same address. But
with List<string> they get copied. However with List<unowned string> they
would be equal. It would be better if you could reword that comment about
pointing to the ownership of the List elements

On Fri, Mar 18, 2016 at 8:26 PM, MohanR <mohan...@gmail.com> wrote:

> 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;
> }
> _______________________________________________
> vala-list mailing list
> vala-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/vala-list
>



-- 
NixOS Linux <http://nixos.org>
_______________________________________________
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to