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

[SP]| somevar != someconst ? return -7 : null | and got invalid expresion


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fakuivan
Senior Member
Join Date: Nov 2015
Old 12-05-2015 , 23:18   [SP]| somevar != someconst ? return -7 : null | and got invalid expresion
Reply With Quote #1

Hi there!

|Read the title|

Any clean workarounds?
fakuivan is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 12-05-2015 , 23:28   Re: [SP]| somevar != someconst ? return -7 : null | and got invalid expresion
Reply With Quote #2

PHP Code:
int num = (somevar != someconst ? -0)
if (
num)
    return 
num

Last edited by Mathias.; 12-05-2015 at 23:28.
Mathias. is offline
fakuivan
Senior Member
Join Date: Nov 2015
Old 12-05-2015 , 23:33   Re: [SP]| somevar != someconst ? return -7 : null | and got invalid expresion
Reply With Quote #3

Quote:
Originally Posted by Black-Rabbit View Post
PHP Code:
int num = (somevar != someconst ? -0)
if (
num)
    return 
num

somevar != someconst ? return -7 : null

I don't want to assign values, retrun and null are supposed to be expressions. I could just do and it's even simpler

Code:
if (somevar != someconst)
    return -7;
:/

Last edited by fakuivan; 12-05-2015 at 23:44.
fakuivan is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 12-06-2015 , 03:57   Re: [SP]| somevar != someconst ? return -7 : null | and got invalid expresion
Reply With Quote #4

PHP Code:
return (somevar != someconst) ? -0
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 12-06-2015 , 08:30   Re: [SP]| somevar != someconst ? return -7 : null | and got invalid expresion
Reply With Quote #5

can't have statements there o.o
Miu is offline
fakuivan
Senior Member
Join Date: Nov 2015
Old 12-06-2015 , 11:16   Re: [SP]| somevar != someconst ? return -7 : null | and got invalid expresion
Reply With Quote #6

Quote:
Originally Posted by KissLick View Post
PHP Code:
return (somevar != someconst) ? -0
I don't want to return 0, I want to do nothing if the condition evaluates to false
fakuivan is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 12-06-2015 , 11:29   Re: [SP]| somevar != someconst ? return -7 : null | and got invalid expresion
Reply With Quote #7

Quote:
Originally Posted by fakuivan View Post
I don't want to return 0, I want to do nothing if the condition evaluates to false
Then use what you posted in https://forums.alliedmods.net/showpo...20&postcount=3
WildCard65 is offline
fakuivan
Senior Member
Join Date: Nov 2015
Old 12-06-2015 , 13:45   Re: [SP]| somevar != someconst ? return -7 : null | and got invalid expresion
Reply With Quote #8

Quote:
Originally Posted by WildCard65 View Post
So, there is no clean way to solve this. I think I will just do

Code:
somevar != someconst ? return -7 : somevar = somevar
fakuivan is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 12-06-2015 , 13:56   Re: [SP]| somevar != someconst ? return -7 : null | and got invalid expresion
Reply With Quote #9

you can't :V
Miu is offline
thecount
Veteran Member
Join Date: Jul 2013
Old 12-06-2015 , 13:56   Re: [SP]| somevar != someconst ? return -7 : null | and got invalid expresion
Reply With Quote #10

Quote:
Originally Posted by fakuivan View Post
So, there is no clean way to solve this.
You can't use 'return' in an expression like that. Best way to get around this is to, god forbid, use an if statement.
PHP Code:
if(somevar != someconst){ return 7; } 

Last edited by thecount; 12-06-2015 at 13:57.
thecount is offline
Reply


Thread Tools
Display Modes

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 10:38.


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