Re: [Vala] Converting nullable to non-nullable types
- From: Abderrahim Kitouni <a kitouni gmail com>
- To: Sam Wilson <tecywiz121 hotmail com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] Converting nullable to non-nullable types
- Date: Fri, 26 Feb 2010 11:22:07 +0100
hi,
2010/2/26, Sam Wilson <tecywiz121 hotmail com>:
Hey!
I am just wondering if there is any syntactic sugar for shortening the
following code segment
[code]
Element? nsource = ElementFactory.make("filesrc", "file-source");
if (nsource == null) { printError(); return; }
Element source = (Element)nsource;
[/code]
I beleive that last line can become
var source = (!) nsource;
and I even think the intended behaviour (right now it's a TODO in vala
source) of non-null cast is to be like this (if the var is null, log a
critical warning and return), so at some point, you should be able to
write this in one line (assuming you beleive the returned value should
be non null for your aguments).
HTH,
Abderrahim
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]