In response to Nadrew
Nadrew wrote:
if(something = somethingelse) does not work because = isn't an expression.

if(something == somethingelse) works because == is an expression.

Get it?

Actually, neither = nor == are expressions. The first is an assignment operator, and the second is a comparison operator. The expression is what is supposed to appear within the parenthesis.

if(something = somethingelse) does not work because something = somethingelse is an assignment.

if(something == somethingelse) works because something == somethingelse is an expression.
In response to Skysaw
Skysaw wrote:
Actually, neither = nor == are expressions. The first is an assignment operator, and the second is a comparison operator. The expression is what is supposed to appear within the parenthesis.

if(something = somethingelse) does not work because something = somethingelse is an assignment.

if(something == somethingelse) works because something == somethingelse is an expression.

This brings up a question. It isn't because I need it or anything, im just curious.

I know this works in C:

int a,b,c,d
if((a=b+c)==d)

Why doesn't it work in DM?

Alathon
In response to Alathon
Alathon wrote:
This brings up a question. It isn't because I need it or anything, im just curious.

I know this works in C:

int a,b,c,d
if((a=b+c)==d)

Why doesn't it work in DM?

Because in C, all procedures are considered functions, and all return results. So, for instance:

a = (b = 2)

will set b to 2, and a to 1. Assigning b=2 returns TRUE if successful, and a boolean value of TRUE is equal to 1.
Page: 1 2