Tangent: Generics Part 1

Published November 03, 2008
Advertisement
At least the most cursory of generics now work in source:
public class foo{    public T x;}public static void main(){    local foo<int> bar = new foo<int>;     bar.x = 5;//  bar.x = "foo!";                // error, no assignment to int from string.    print bar.x;    local foo<string> baz = new foo<string>;    baz.x = "moocow.";    print baz.x;    local foo fooany = new foo;    fooany.x = "moocow.";//  print fooany.x;                 // error, print can't take 'any'}


Now on to methods.
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement