need help in ternary operator
#1

I'm not really good in TO so I'm not sure what could be the reason of this problem.
pawn Code:
(db_num_rows(Result)) ? ShowPlayerDialog(playerid, dlogin, DIALOG_STYLE_INPUT, ""horange"LOGIN", "test", "Login", "Quit")
        : ShowPlayerDialog(playerid, dregister, DIALOG_STYLE_INPUT, ""horange"REGISTER", "test", "Register", "Quit");
Code:
warning 215: expression has no effect
Reply
#2

Youre using a long length how about strcat
Reply
#3

Nope. If I did this
pawn Code:
(a == b) ? c = d : c = e;
I'll still get the same warning.
Reply
#4

make them in format string
Reply
#5

Sorry, but I don't understand you. You mean, the dialog?

EDIT: Edited main post.
Reply
#6

I don't see the point of using the ternary syntax for something like that just use if/else it makes absolutely no difference once it's compiled.
Reply
#7

pawn Code:
if(db_num_rows(result))
{
    ShowPlayerDialog(.....);
}
else
{
    ShowPlayerDialog(.....);
}
//Looks ugly

(db_num_rows(result)) ? ShowPlayerDialog(....) : ShowPlayerDialog(....);
//Looks simple and clean!
Reply
#8

Quote:
Originally Posted by newbienoob
View Post
Nope. If I did this
pawn Code:
(a == b) ? c = d : c = e;
I'll still get the same warning.
That would be something like
pawn Code:
c = (a == b) ? d : e;
I'll edit this for the main post
Reply
#9

Quote:
Originally Posted by newbienoob
View Post
pawn Code:
if(db_num_rows(result))
{
    ShowPlayerDialog(.....);
}
else
{
    ShowPlayerDialog(.....);
}
//Looks ugly

(db_num_rows(result)) ? ShowPlayerDialog(....) : ShowPlayerDialog(....);
//Looks simple and clean!
Ternary operators are useful in many, many cases, but they _don't_ make your code easier to read.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)