Created
January 1, 2018 11:07
-
-
Save kosmolot/a555323baf1d67f473ff9bbf30cc9dd0 to your computer and use it in GitHub Desktop.
Wildcards in vala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Container<T> : Object { | |
public T value { get; set; } | |
public Container (T value) { | |
_value = value; | |
} | |
} | |
void main () { | |
Container<void*> obj; | |
// (Container<void*>) <- required because 'int' is not a pointer type | |
obj = (Container<void*>) new Container<int>(111); | |
print("hello %d!\n", ((Container<int>)obj).value); // hello 111! | |
// (Container<void*>) <- NOT required because 'Container' is a pointer type | |
obj = new Container<Container<int>>( new Container<int>(222) ); | |
print("hello %d!\n", ((Container<Container<int>>)obj).value.value); // hello 222! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment