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

Tangent: Generics Part 1

Sign in to follow this  
Telastyn

90 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!