Day 2.3 Exercise 6 Strings and Text

Here’s my work on GitHub.
Here’s the link to the exercise 6.

Ex06 Code
Ex6 Code

 

Ex06 Shell
Ex6 output

Study Drills

1. Go through this program and write a comment above each line explaining it.
Nah, I’ll skip the puts. I’m sure Zed is yelling at me right now.

2. Find all the places where a string is put inside a string. There are four places.
x, y, binary, do_not.

3. Are you sure there are only four places? How do you know? Maybe I like lying.
Yes, there is one more. hilarious = false, eventhough it’s boolean, but it’s kinda passed on as a string.

4. Explain why adding two strings w and e with + makes a longer string.
It’s known as concantenation. Not really math here.

5. What happens when you change the strings to use ‘ (single quote) instead of ” (double qoute)? Do they still work? Try to guess why.
Double quotes are used when you have some kind of escape such as #{} or \n. If you do single quotes ‘, the strings inside are read just the way it is, nothing is computed, example, if you do ‘y’ as seen above, it gets read at y, instead of the y variable.

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