View Single Post
Author Message
BAILOPAN
Join Date: Jan 2004
Old 12-17-2018 , 01:50   Enum Structs Available This Holiday Season
Reply With Quote #1

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);

__________________
egg

Last edited by BAILOPAN; 03-10-2019 at 19:19.
BAILOPAN is offline