Term
|
Definition
command to output things in Ruby. puts "Hello world!" would print "Hello world!" |
|
|
Term
|
Definition
pound sign, used to comment out code on its own line. Also used within a puts command to signal a variable, e.g., puts "This is a #{variable}" |
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
asterisk, used in math to multiply |
|
|
Term
|
Definition
percent, used in math to take the following number percentage of an original number. For example, 100 % 2 takes 2% of 100. |
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
a string of letters or words; anything between double quotes. EG, "This is a string". Strings are what the program gives to humans. |
|
|
Term
|
Definition
Used to insert a variable in a string. Format is like puts "this is a string with a %s" % variable.
For multiple variables, it looks like, "This is a string with a %s and a %s" % [first_variable, second_variable]. |
|
|
Term
|
Definition
A second way of inserting variables into strings. |
|
|
Term
|
Definition
Allows you to create a multi line string. Format is puts >>PARAGRAPH string string string PARAGRAPH |
|
|
Term
|
Definition
Creates a new line in a string. |
|
|
Term
|
Definition
creates a tab in a string |
|
|
Term
|
Definition
Creates a single backslash (one backslash signals an escape command, the second signals you want just one backslash). |
|
|
Term
|
Definition
Similar to puts, but doesn't create a new line. |
|
|
Term
|
Definition
gets accepts a single line of data input by the user, chomp is a string method. |
|
|
Term
|
Definition
Opens a library in ruby to use? |
|
|
Term
|
Definition
Argument variable = takes input when running the program and assigns it to a variable. Is constant, so doesn't change.
EG, if you run ruby ex1.rb test1 test2 test3 then test1 would be assigned to the first ARGV variable, test2 the second, etc. |
|
|
Term
|
Definition
Explicitly tells the .gets command to read from a user's input, instead of trying to read the input as a file. (see exercise 14) |
|
|
Term
|
Definition
reads the text file content; when puts txt.read() will print the content of a text file. |
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
Reads just one line of a text file. |
|
|
Term
|
Definition
Empties the file, watch out if you care about the file. |
|
|
Term
|
Definition
Writes stuff to the file. |
|
|
Term
|
Definition
starts defining a function |
|
|
Term
|
Definition
used to offset variables within ruby code. Example: puts "Here is a #{variable}" % variable |
|
|
Term
|
Definition
|
|