Learn Ruby the Hard Way – Exercise 2 Comments and Pound Characters

Here is my work for Exercise 2.

Exercise 2 code
Exercise 2 code
Exercise 2 Output
Exercise 2 Output

Study Drills
1. Find out if you were right about what the # character does and make sure you know what it’s called (octothorpe or pound character).

The octothorpe or pound character tells Ruby that the line is going to be a comment. Code after a pound character will not be run by Ruby.

2. Take your ex2.rb file and review each line going backward. Start at the last line, and check each word in reverse against what you should have typed.
Done.

3. Did you find more mistakes? Fix them.
I didn’t find any mistakes, whew!

4. Read what you typed above out loud, including saying each character by its name. Did you find more mistakes? Fix them.
None found.

Takeaway thoughts:
Reading code backwards is a great way to separate the meaning of the words from the code itself. I can see this as being a great way to debug code or to fix text typos and errors. The mind has a great tendency to “fix” mistakes in texts by itself, so forcing the brain to separate each word is a good way to catch mistakes.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s