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

Tangent: Method Tests Part 3

Sign in to follow this  
Telastyn

172 views

A few of the fruits from the last big refactoring to show today. Phrases now can act as generators, and delegates can nicely deal with generators:



public static nums() => yields<int>{ yield(0); yield(1); yield(2); }
public static some nums => yields<int>{ yield(0); yield(1); yield(2); }
public static good many nums => yields<int>{ yield(0); yield(1); yield(2); }
//
// bug #39
//public static (int min) to (int max) => yields{ int x = min; do{ yield(x); x = x+1;}while(x

public static delegate yieldDel() => yields<int>;


public static main()=>void{

foreach(int x in nums()){
print x;
}

foreach(int x in some nums){
print x;
}

foreach(int x in good many nums){
print x;
}

yieldDel = nums;
foreach(int x in yieldDel()){
print x;
}
}




012012012012


Infix methods as generators don't quite work yet, but at least I identified that. They'll work soon enough.
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!