Re: [Vala] How do you get from the generic, to the.....specific?
- From: ant <blowback gmail com>
- To: vala-list gnome org
- Subject: Re: [Vala] How do you get from the generic, to the.....specific?
- Date: Sat, 18 Feb 2012 23:10:49 +0000
On 18 February 2012 21:56, Evan Nemerson <evan coeus-group com> wrote:
Thanks for the comprehensive answer, it was most useful!
You seem to be operating under a pretty fundamental (though
understandable) misunderstanding about how Vala generics work. This
came up on stackoverflow recently, so you're not alone.
Heh, you're not wrong there!
public int get_length<T> (T val) {
if ( typeof (T) == typeof (string) ) {
return ((string) val).length;
} else {
GLib.error ("Unable to handle type `%s'", typeof (T).name ());
}
}
Thanks, that's exactly what I was after.
cheers
ant
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]