Vala: Gotchas, Tips and Tricks

后端 未结 9 1667
情书的邮戳
情书的邮戳 2021-01-30 13:04

As a programmer who is new to Vala, what is your number one piece of advice to someone who is new to the language?

9条回答
  •  抹茶落季
    2021-01-30 13:42

    Generally, Vala is excellent, but the one big gotcha I've found is that either its handling of arrays is very primitive compared to the rest of the language or its documentation has a very gaping hole in it.

    Despite a long, hard look through the documentation, tutorials, and Google, I've concluded that:

    • The only way to concatenate two arrays is either to fall back to C-style tricks or use foreach and += to manually add one array to the other element-by-element.
    • You can do a slice like argv[1:-1] but there seems to be no syntax for equivalent to Python's argv[1:], so you have to fall back to something more procedural for that.
    • Libgee is useless to me because, while Gee objects have methods like add_all, none of them take C-style arrays, so I'm back to using add with foreach and +=.

提交回复
热议问题