x


"Expressions in statements must only be executed for their side effects." ERROR.

I'm getting an "Expressions in statements must only be executed for their side effects." error. What am I doing wrong?

more ▼

asked Jul 27, 2010 at 05:56 AM

MikezNesh gravatar image

MikezNesh
993 181 150 166

(comments are locked)
10|3000 characters needed characters left

4 answers: sort voted first

It means you have a statement in your code that doesn't DO anything - it doesn't alter any state and thus doesn't have any effect on anything. That is seen as an error.

One example of this could be if you have a line like this (where MyFunction is a function declared elsewhere):

function Update () {
    MyFunction;
}

In this code there is a statement which just states the reference to MyFunction but doesn't do anything with it. If you wanted to call the function, you should remember the paranthesis:

function Update () {
    MyFunction();
}

Now the code actually calls MyFunction, so it's not seen as a coding error anymore.

more ▼

answered Jul 27, 2010 at 08:24 AM

runevision gravatar image

runevision ♦♦
9.2k 54 111 173

Thanks. Really like your locomotion system by the way :D

Jul 27, 2010 at 07:00 PM MikezNesh
(comments are locked)
10|3000 characters needed characters left

Could be several things...this error message is discussed here.

more ▼

answered Jul 27, 2010 at 06:27 AM

Eric5h5 gravatar image

Eric5h5
111k 55 189 675

(comments are locked)
10|3000 characters needed characters left

An additional example that's not a function missing brackets:

I've been stuck with this error for accidentally putting the statements of a For loop in the wrong order. Due to the rarity of the traditional For(Intialisation;Condition;Increment) structure in my code, (and lack of syntax reference in the help file) this elementary error took a while to spot.

Placing my order as For(Intialisation;Increment;Condition), it tried to treat a condition as a change. Which is how I think I got this error.

more ▼

answered Dec 03, 2010 at 03:19 PM

Novodantis 1 gravatar image

Novodantis 1
1.8k 28 33 56

(comments are locked)
10|3000 characters needed characters left

x==1;

this is the same error must be

x=1;

more ▼

answered Aug 23, 2013 at 10:25 PM

przem997 gravatar image

przem997
0

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3634
x207
x10
x5

asked: Jul 27, 2010 at 05:56 AM

Seen: 14985 times

Last Updated: Aug 23, 2013 at 10:25 PM