[Vala] Using 'as' for casting?



When converting my application to use Gtk.Builder I ended up with a
lot of code like this:

var lbl = builder.get_object("foo") as Gtk.Label;

And this caused me to try the following:

var time = Time.gm (unxtime as time_t);

as it was more readable than:

var time = Time.gm ((time_t) unxtime);

This however is not valid syntax, but maybe it should be? On IRC I got
the answer that if an 'as' would fail it would return null, and that's
why it shouldn't work.

I thought it was best to drop a mail to the list and see what people think.

-- 
Daniel Svensson



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