Raised This Month: $51 Target: $400
 12% 

Enum Structs Available This Holiday Season


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:21.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode