Learn Ruby the Hard Way – Exercise 22 What do you know so far?

First, go back through every exercise you have done so far and write down every word and symbol (another name for “character”) that you have used. Make sure your list of symbols is complete.

Next to each word or symbol, write its name and what it does. If you can’t find a name for a symbol in this book, then look for it online. If you do not know what a word or symbol does, then read about it again and try using it in some code.
Whoa, every word and symbol that I have used? That’s pretty intimidating… let’s see how well I do.

puts prints a line to the screen with a new line character to the end
print prints a line, without a new line character at the end
variable an name that contains an associated value
“” double quotation marks, used to enclose strings
# octothorpe or pound symbol, for writing comments
+ plus, used to add numbers or strings
minus, used to subtract
/ slash, used for division
* asterik, used for multiplication
% percent, used for modulo operations
< less than
> greater than
<= less than or equal to
>= greater than or equal to
#{} used for string interpolation, the code inside will be evaluated
= assignment operator, assigns values
single quotation marks, also used for strings (cannot do string interpolation)
true a boolean value
false a boolean value
%{} formatter for strings
“”” triple quotation marks, used for multi-line strings
\t tab
\n new line character
\\ backward slash
gets a method, used to get standard input or to read one line of a file object at a time
() brackets, can be used to enter parameters
chomp a string method, used to remove the new line character at the end of the string
.to_i a method, changes a string to an integer
ARGV the argument value, holds arguments that are entered on the command line
$stdin standard input, used when arguments are entered on the command line to differentiate between $stdin.gets and kernel#gets
open(filename) a method that takes a filename as a parameter and returns file objects
read a file object method, returns the content of the file as a string
.truncate() a file object method, changes the file size to integer bytes
.write a file object method, writes the given string to the file
.close a file object method, closes the file
.length a string method, returns the length of a string
.exist? returns true if a file exists, returns false if not
*args used for multiple arguments, creates a list of arguments
def…end defines a function
.seek moves a file’s position indicator to specified location
+= positive increment, variable += increment is the same as variable = variable + increment
return used to exit a function and return the specified value to the function caller

Takeaway Thoughts
Although this exercise felt a bit tedious, it was a good way to review and reinforce the things I have learned so far.


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