Lesson 4: If, For, And, Not, Or

Blog post by darkwyrm on Fri, 2010-02-05 23:34

Hey, that rhymes even! :P Lesson 4 is now out. Decision-making and repeating instructions are on the agenda for this one, expanding the repetoire of basic skills for writing code. Learning to Program With Haiku, Lesson 4.

Comments

Re: Lesson 4: If, For, And, Not, Or

Thank's darkwyrm!!!

Re: Lesson 4: If, For, And, Not, Or

Thank you very much for taking the time to write these lessons, darkwyrm. These are worth their bytes in gold.

Re: Lesson 4: If, For, And, Not, Or

If variables can be declared using the equals operator, why is 'int' used?

Thanks.

Re: Lesson 4: If, For, And, Not, Or

If variables can be declared using the equals operator, why is 'int' used?

Variables can't be declared using the equals operator. At least they can't in C/C++. You've misunderstood something I guess.

Example:

// this means: variable "a" of integer type, initial value "3"
int a = 3; 
// quite the same, just longer:
int b;
b = 3;

Re: Lesson 4: If, For, And, Not, Or

But, they can be changed with just an equals, right?

Sorry, this is quite different from the only language that I know, BBC BASIC (excluding assembly).

Re: Lesson 4: If, For, And, Not, Or

That is correct. :)

Re: Lesson 4: If, For, And, Not, Or

Small typo in the Boolean examples;

For the Boolean Value of NOT, the example says if ( !(a == 1 || b == 2) ) and it says that means "if the opposite of a equaling 1 and b equaling 2", but it should say "if the opposite of a equaling 1 OR b equaling 2".

It would need to say if ( !(a == 1 && b == 2) ) for it to be "if the opposite of a equaling 1 and b equaling 2".

Correct?