Raised This Month: $ Target: $400
 0% 

Methodmap: Default parameters switching with value of "this"


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
humbugtheman
Member
Join Date: Jan 2012
Old 03-07-2016 , 17:26   Methodmap: Default parameters switching with value of "this"
Reply With Quote #1

Can anyone point out if I'm doing something wrong? I swear this shouldn't be happening.
Basically...

* I have a function that returns a 'type' that I have defined in a methodmap.
* I use one of its methods on it.
* That method has a default parameter in it.
* If I leave that parameter blank, the values of "this" and the default parameter seem to switch.

PHP Code:
methodmap Calculator {
    
    public 
Calculator(int id){
        return 
view_as<Calculator>(id);
    }
    
    public 
int Add(int aint b 666){
        
PrintToServer("B = %i"b);
        
PrintToServer("CALC ID = %i"this);
        return 
b;
    }
}

public 
void OnPluginStart(){
    
Calculator(42).Add(23);
    
Calculator(42).Add(2);

Result:
HTML Code:
B = 3         // expected 3
CALC ID = 42  // expected 42
B = 42        // expected 666
CALC ID = 666 // expected 42
Please let me know if I'm being stupid. Otherwise I can report a bug. Thank you!

Last edited by humbugtheman; 03-07-2016 at 17:34.
humbugtheman 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 23:23.


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