Day 3.1 Exercise 13 Parameters, Unpacking, Variables.

Here’s my work.
Here’s the link to the exercise 13.


Ex13 Code
Ex13 Code with extra messing around
Ex13 Shell
Ex13 Output

I’ve modified the code just a little. There are .upcase , .capitalize , .downcase, if, else, end.

These are new, I’m trying to use what I’ve learned and tweak them a little to do what some times real work requires to do.

Study drill

1. Try giving fewer than three arguments to your script.
Yes, it will shows up blank. You can use the if else statement to show an error and stop computing the rest of the code by type exit(0).

2.Write a script that has fewer arguments and one that has more, make sure you giv the unpacked variables good names.
Less arguments would cause it blank, more arguments than listed will be ignored.

3. Change your script to use #stdin.gets.chomp everywhere that you have gets.chomp. You should use $stdin.gets.chomp from now on since the action gets.chomp has problems with ARGV.
Yes sir.

4.Now that you are using $stdin.gets.chomp (see #3) you can add ARGV to your script ro get something from the user. Don’t over think this. Just use ARGV to get one thing, then $stdin.gets.chomp to get something else.
Done, please look on the code above.


Leave a Reply

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

You are commenting using your 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