Jump to content
  • Advertisement
  • entries
    359
  • comments
    237
  • views
    189105

Tangent: Generics Part 1

Sign in to follow this  
Telastyn

77 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
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!