View Single Post
  #23   Spotlight this post!  
Unread 28-04-2010, 11:33
Andrew Schreiber Andrew Schreiber is offline
Joining the 900 Meme Team
FRC #0079
 
Join Date: Jan 2005
Rookie Year: 2000
Location: Misplaced Michigander
Posts: 4,077
Andrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond repute
Re: List of Killer Bee Bot Bottoms

Quote:
Originally Posted by Schnabel View Post
I found an error in your code, let's debug:


In this setting, 33 is your variable (assuming you defined it earlier). Let's assume 33 is currently set to null. In your example above, you are saying "If set 33 to Team then call Win" However Team is not a valid variable, instead it should be 'Team'. So that would kill you first. THEN you are setting 33 to Team, I think you would rather do a Binary test now wouldn't you? You would rather it be "If 33 is Team then call Win" which would require double =. So for this statement to function properly, you should have wrote:
If (33 == 'Team') WIN();
Quote:
Originally Posted by apalrd View Post
I disagree. == is not =.
= sets one variable to another. == checks for a comparison. so I am checking that team is equal to 33, if it is, then win. The order does not matter.
Actually, in C (or C++), it is better to put the constant before the variable, in case you forget the second =, so the compiler will give you an error for setting a constant instead of getting some crazy error at runtime.

EDIT: I see that BJC forgot the second =. The actual one says "if (33==team) win();"
Language dependent. For example, in one of the languages I use for "fun" development checking for equality between numbers is done with the syntax: (= 33 Team).

But Andrew does make a good point, writing it Constant == variable is a great way of making the compiler check for your typos in C/C++. Why do more work when you can make a computer do it for ya?


33, will there bee more unique ones for offseason events?
__________________




.
Reply With Quote