[Vala] Generics and .to_string()
- From: Albert Hopkins <marduk letterboxes org>
- To: vala-list gnome org
- Subject: [Vala] Generics and .to_string()
- Date: Wed, 20 Feb 2013 07:51:21 -0500
I would like to use a Generic class, so
class MyClass<T> {
T property;
...
public void Print() {
stdout.printf(property.to_string())
}
}
The compiler fails with:
The name `to_string' does not exist in the context of `T'
And that does kinda make sense to me, the question is.. I guess in a
generic fashion:
How can I call a method on a Generic type? For the above example, I've
tried casting:
((Object) property).to_string() tells me that GLib.Object has no
to_string() (I thought it did, but may have confused it with C#'s
object.
(string) property compiles but segfaults.
Is there an Interface for to_string() i can check for, e.g:
if (property is IStringable) ((IStringable) property).to_string()
Thanks,
-a
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]