Why "if..else.." deosn't work?

1
The result is “null”, how to fix it?

HI
like this:

def y_coor(x)
{
	return=[Imperative]
	{
	if (x>0)
	{
	return=1;
	}
	else
	{
	return=-1;
	}
	}
};
y_coor(1);
1 Like

Hi @Xiaofei_Ying

You could also create a simple statement with

X > 0 ? 1 : -1 ;

2 Likes