Day 20: Pushing Through the Fatigue to Keep Learning Ruby

So, today was a day from hell! It was a 10 hour day and chaotic for the most part.

Exercise 22: What Do You Know So Far?

Today’s took forever but seemed a valuable review:

putsput string; it returns the string to the user when ran
# CommentYou use the hashtag to start a comment that is not displayed to the user but is instead able to be read by a developer or someone else reading the code
+plus; adds
*asterik; multiplies
-minus; subtracts
/slash; divides
<less than
>greater than
<=less than or equal
>greater than or equal
%percent sign; modulus; Divides left hand operand by right hand operand and returns remainder (I am still not 100% sure of how the percent sign works.)
floating pointa number with a decimal point
_underscore; puts an imaginary space in a variable name
#{}Used to embed a variable in a string
=assigns the variable on the right to the variable on the left
!ERROR! unexpected operator '='tests if the two things have the same value
stringHow you make something that your program may give to a human
" "Surrounds a string
boolean valuestrue or false
printdisplays the result of evaluating Ruby code; puts adds a new line after executing and print does not add a new line
%{}A way to apply the same format to multiple variables.

Used to make a multiple line string
\nnew line
\ttab a line
\" and \'Used in the middle of a string when a quote is needed in the string so as not to end the string prematurely.
(escape sequences)I did all of these a few days back, so go see that table!

prints everything inside them exactly, regardless of the code inside it
getsasks for input from the user
gets.chompthe .chomp method gets rid of any Enter characters at the end of a string
gets.chomp.to_iTakes user input from gets.chomp and converts it into an integer
gets.chomp.to_fGets the user input and converts it into a floating decimal
ARGVAsks for user input at the command line
.rbthe format you save the ruby files to
$stdin.gets.chompSo, stdin is standard input which I believe, with help from the codenewbie slack channel, refers to the command line, so that means it is taking the input from the command line and
promptused to change the prompt symbol
.readReads the contents of the file. You can assign the result to a variable.
open opens the indicated file
.truncateEmpties the file
target.writewrites to the file
wa write flag
closecloses the file
readlinereads one line of the file
File.exist?(to_file)Checks whether the indicated file is on the disk
defused to create a function; define
*argsUsed for arguments in a function; the * tells Ruby to take all the arguments in the function and put them in args as a list
rewindTells Ruby to go back to the beginning of a file
print_allprints the entire file out
fvariable for file
current_lineselects the current line
print_a_lineprints the current line
+-variable + 1
seek()seeks to a byte, not a line
returntells Ruby to return something explicitly

I won’t be pausing here to learn it over and over. I will push on, but will review this.