Re: [Vala] Variable declaration.



Hi Alexandre,

On Son, 2007-03-11 at 12:43 -0300, Alexandre Moreira wrote:
Hey there, everyone.

Can I use type names (class names, actually) while declaring variables
or only the "var" keyword ?

Yes, you can use type names.

If I can use the type names, what is the value of having the var
keyword ? Anything specific needs it ? Just asking because I think it
would be a pain in the neck to write some sort of code completion with
variables defined with "var" lots of checking to do to find out its
type.

There is no specific need currently, it just eases writing code
sometimes quite a bit. I wouldn't recommend to always use var as the
readability might suffer but statements like this
        HashMap<string,string> map = new HashMap<string,string> ();
are just nicer to write like that
        var map = new HashMap<string,string> ();

It doesn't make sense, in my opinion, to use it for basic types like
        var b = false;

It's planned to provide API in libvala that will make it easy to write
code completion support.

Jürg




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]