Jump to content
  • Advertisement
  • entries
  • comments
  • views

Tangent: Generics Part 1

Sign in to follow this  


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  


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!