Jump to content
  • Advertisement
  • entries
  • comments
  • views

Tangent: Method Tests Part 2

Sign in to follow this  


Not much time for hobby this weekend. I managed to setup some delegates and make sure they work like they're supposed to. The example code, which includes infix delegates and a quick example of the partial application built into the language:

public static foo() => void{ print "foo.";}
public static bar(string s) => void{ print s;}
public static baz(string s, int i) => void{ print s i;}
public static phrase(string s) (int i) => void{ print s i;}
public static how now brown cow => void{ print "MOO!";}
public static test (int lhs) times (int rhs) => int{ return lhs * rhs; }
public static (int lhs) op (int rhs) => int{ return lhs * rhs; }
public static (string lhs) * (string rhs) => string{ return lhs + rhs; }
public static (string lhs) ++ (string rhs) => string{ return lhs + rhs; }
public static (int x) a b => int{ return x+5; }

public static delegate voidDel() => void;
public static delegate (string lhs) opDel (string rhs) => string;
public static delegate what now brown cow => void;
public static delegate cowDelegate cow => void;

public static main()=>void{
bar "moo.";
baz ("bleat.",6);
phrase "bleat." 42;

how now brown cow;

print test 4 times 6;
print 2 op 3;
print "moose:" * " umm. moose.";
print "moose:" ++ " umm. moose.";

//print 5 a b; // bug #37

voidDel = foo;

opDel = +;
print "moo" opDel "cow";

opDel = ++;
print "bleat" opDel "sheep";

what = how;
what now brown cow;

cowDelegate = how now brown;
cowDelegate cow;

voidDel = ()=>void{ print "llllama."; };

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!