• entries
    359
  • comments
    237
  • views
    188610

Tangent: Generics Part 1

Sign in to follow this  

68 views

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.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now