View Full Version : Resolved Need help understanding a line of code

Nov 18th, 2009, 11:17 AM
Hi, I'm trying to do an assignment, and have copied a piece of code to learn while I do, if you see what I mean. Problem is, I'm having real trouble with one of the lines of code. If someone could tell me basically what it does, I'd be very greatful!
Here's the code:
if (height[i] == -(array[i].height))

The - before (array[i].height) is really confusing me!
Thanks in advance!

Nov 18th, 2009, 11:39 AM
That's a math minus. What confuses me is what array[i].height might be. A custom property?

Philip M
Nov 18th, 2009, 11:43 AM
if (height[i] == -(array[i].height))

Meaningless. I suggest it is a grotesque misprint.

Possibly intended to be something like

if (height[i] == height[i-1] ) .......

If you posted all the (relevant) code it would probably be more apparant.

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

Nov 18th, 2009, 11:50 AM
Yeah, it's custom.
array is (obviously) my array and the height, is the value of the height of the image that i'm using for calculations. height is another array which holds the height of the entire stack of images up to that point in the array.
I'm making a scrolling image marquee and that line (i know) has something to do with making it continuous. However, I have no idea as to what type of math it is doing with that minus sign there. It's definitely important that it is there, because when I remove the minus, the first two images (in array positions 0 and 1) do not repeat, while all the rest do.
Very confusing.
(also I am hesitant to post entirety of script here due to it being an assignment)

Nov 18th, 2009, 02:42 PM
Ok, I sat down and worked on the code one line at a time and figured out that it is just a negative number that it is comparing the height to!
Thanks to the people who replied for their input!!