Raised This Month: $101 Target: $400
 25% 

[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-06-2015 , 00: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 The Vegan
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 12-06-2015 , 00: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 The Vegan; 12-06-2015 at 00:28.
Mathias The Vegan is offline
fakuivan
Senior Member
Join Date: Nov 2015
Old 12-06-2015 , 00: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-06-2015 at 00:44.
fakuivan is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 12-06-2015 , 04: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 , 09: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 , 12: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 , 12: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 , 14: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 , 14: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 , 14: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 14: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 07:04.


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