#Day 5
begin rescue end
example=
puts "Welcome"
print "What do you want to divide by?" divisor = gets.to_i
begin puts "The result of 3 divided by #{divisor} is #{3/divisor}" rescue puts "the divisor is no good " end
--> If the user enters the number 0, 3 cannot be divided by 0 so it calls the rescue string.
####Error messages
-
"rescue" displays an error if your code crashes.
-
"raise" forces a method to occur
Kernel.error = quits the program
-
"retry" retries the code
-
"ensure" ensures the code below will be executed
See file exceptions.rb in Projects folder
####File I/O
(see file-io.rb) --> we created a new file within a file that prompts the user to input data that will be stored in the file "database.txt"
In the Terminal: /"word" -> helps you find a word in your code less "name file" allows you to see your code back and up.
less database.txt allows you to see your code and see where it ends
.strim cleans up a value in an array
double click on variable and click Command-D to select the other places the variable is mentionned to change all of them
def to_s - changes to string?
####Testing
rspec
dsl = domain specific language
to break numbers into more readable stuff we can separate with "_"