Lesson 6: More Loops and Conditions

Blog post by darkwyrm on Sat, 2010-02-20 01:25

Here marks the beginning of the second unit in my series, "Learning to Program With Haiku." Lesson #6 expands on our knowledge of loops and decision-making constructs. Good luck! Learning to Program With Haiku, Lesson 6.

Comments

Re: Lesson 6: More Loops and Conditions

Nice lesson, DarkWyrm.
WRT the switch-case-thingy: So, the "break;" in a default switch-case is actually optional. Should one put it in there or not? On the one hand it signals that it will definitely break out at this place, on the other hand this could tempt you to simply remove it, erroneously thinking this would then execute the following code...

Two tiny typos on page 5:

  • Using our above example, leaving out the break at the end of the case for spaces would cause the it to be printed twice:
  • Hold on there, cowboy! What's this here nonsense?

Regards,
Humdinger

Re: Lesson 6: More Loops and Conditions

Humdinger wrote:

Nice lesson, DarkWyrm.
WRT the switch-case-thingy: So, the "break;" in a default switch-case is actually optional. Should one put it in there or not? On the one hand it signals that it will definitely break out at this place, on the other hand this could tempt you to simply remove it, erroneously thinking this would then execute the following code...

Thanks! Technically, a break statement in the default case is optional, though many put it in there out of habit.

Humdinger wrote:

Two tiny typos on page 5:

  • Using our above example, leaving out the break at the end of the case for spaces would cause the it to be printed twice:
  • Hold on there, cowboy! What's this here nonsense?

Regards,
Humdinger

The first one has been corrected. Thanks for pointing it out. :) The second one isn't a typo -- some people here in the US really do talk like that, even if it's not grammatically correct. ;)

Re: Lesson 6: More Loops and Conditions

On the bughunt example, why is the first function declared as a pointer?