View Single Post
Santi.
Member
Join Date: Oct 2010
Location: Cordoba(Argentina)
Old 01-09-2019 , 16:21   Re: Enum Structs Available This Holiday Season
Reply With Quote #19

Quote:
Originally Posted by BAILOPAN View Post
Hi Folks,

As of PR #934, SourceMod 1.10 has support for enum structs. This is some long-overdue syntactic sugar that makes SourcePawn feel more like a real language. Enum Structs are internally implemented as arrays, but the syntax is a lot nicer than before and we've fixed a lot of the corner cases and rough edges around using them. You can also have enum struct methods now.

You can read more about enum structs either in the Transitional Syntax Docs, or in the commit message.

If you're too impatient to read that, I'll just copy and paste the sample code from the doc:

PHP Code:
enum struct Rectangle {
  
int x;
  
int y;
  
int width;
  
int height;
 
  
int Area() {
    return 
this.width this.height;
  }
};
 
void DoStuff(const Rectangle r) {
  
PrintToServer("%d, %d, %d, %d"r.xr.yr.widthr.height);

I love you man.. this is what we needed. Thanks bro!
Santi. is offline