Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
34 Cards in this Set
- Front
- Back
cd |
Change directory, changes the directory to the specified directory on the console |
|
ls |
list contents directory, shows all content (files and folders) of the directory. If no directory is specified shows the contents of the current directory |
|
pwd |
directory you are currently in, shows the full path of the directory you are currently in |
|
mkdir |
create a new directory, creates a directory with the given name in the folder you are currently in |
|
rm |
delete a file, deletes the specified file |
|
rm -r |
delete a directory, deletes the specified folder and all of its contents |
|
program |
starting a program, starts the program with the given name and arbitrary arguments if the program takes arguments |
|
ctrl + c |
abort the program |
|
# |
comment |
|
variable= |
variables |
|
puts |
console output, prints its argument to the console. Can be used in Rails apps to print something in the console where the server is running |
|
object.method(arguments) |
call a method ( length, delete_at, or gsub) calling a method is also referred to as sending a message in Ruby. |
|
def name(parameter) # method body end |
define a method, methods are basically reusable units of behavior. And you can define them yourself |
|
object == other |
Equality; with two equal signs you can check if two things are the same. If so, true will be returned; otherwise, the result will be false |
|
object ! = other |
Inequality; Inequality is the inverse to equality, e.g. it results in true when two values are not the same and it results in false when they are the same |
|
if condition # happens when true else # happens when false end |
With if- clauses you can decide based upon a condition what to do. When the condition is considered true, then the code after it is executed. If it is considered false, the code after the "else" is executed |
|
constant = some_value |
Constants; constants look like variables, just in UPCASE. Both hold values and give you a name to refer to those values. |
|
number_of_your_choice |
normal Number, |
|
main.decimal |
Decimals, achieve decimal numbers in Ruby simply by adding a point |
|
n operator m |
Basic math; in Ruby you can easily use basic math operations. In that sense you may use Ruby as a super-powered calculator |
|
n operator m |
comparison (<> >=); numbers may be compared to determine if a number is bigger or smaller than another number |
|
"A String" |
Create; a string is created by putting quotation marks around a character sequence |
|
"A String and an #{expression}" "Email: #{user.email}" |
Interpolation; you can combine a string with a variable or Ruby expression using double quotation marks |
|
string.length "Hello".length# =>5 "".length #=>0 |
you can send a string a message, asking how long it is and it will respond with the number of characters it consists of. |
|
string+string2 "Hello" + "reader" # => "Hello reader" |
concatenate; concatenates two or more string together and returns the result |
|
string.gsub(a_string,substitute) |
substitute, gsub stands for "globally substitute". It substitutes all occurrences of a_string within the string with substitute. |
|
string[position] "Hello"[1] # => "e" |
Access the character at the given position in the string. Be aware that the first position is actually position 0. |
|
[contents] |
creates an Array, empty or with the specified contents. |
|
array.size [].size # => 0 [1, 2, 3].size # => 3 |
returns the number of elements in an Array |
|
array[position] array = ["hi", "foo", "bar"] array[0] # => "hi" |
As an Array is a collection of different elements, you often want to access a single element of the Array. Arrays are indexed by numbers so you can use a number to access an individual element |
|
array << element array = [1, 2, 3] array << 4 array # => [1, 2, 3, 4] |
Adding an element; adds the element to the end of the array, increasing the size of the array by one |
|
array[number] = value array = ["hi", "foo", "bar"] array[2] = "new" array # => ["hi", "foo", "new"] |
Assigning, Assigning new Array Values works a lot like accessing them; use an equals sign to set a new value. |
|
array.delete_at(i)
array = [0, 14, 55, 79] array.delete_at(2) array # => [0, 14, 79] |
Delete at Index; Deletes the element of the array at the specified index. Remember that indexing starts at 0. |
|
array.each do |e| .. end persons.each do |p| puts p.name end numbers.each do |n| n = n * 2 end |
Iterating, "Iterating" means doing something foreach element of the array. Code placed between do and end determines what is done to each element in the array. |