Intro Flashcards
Familiarize yourself with intro level elements of Ruby
What provides ordered, integer-indexed collections of any object?
An Array
How should text be formatted in Classes?
CamelCase
How should text be formatted in methods, arguments and variables?
in_snake_case
How should text be formatted in constants?
IN_SNAKED_UPPERCASE
How is a ternary operator structured?
puts Boolean ? “expression if true” : “expression if false”
What is a shortcut for creating an array of strings?
array_name = %w{“string”, “string”, “string”}
What is a shortcut for creating hashes?
hash_name = {key: ‘value’, key: ‘value’}
How would you use the .each block to access data in a hash?
hash_name.each { | key, name | puts “#{name} => #{value}”}
What does this produce?
a = %w( ant bee cat dog fish)
a.each { |animal| puts animal}
and bee cat dog fish
What are instance variable names led with?
They are lead with the @symbol
The controller passes off heavy code to what?
The model
What are the 4 major classes and objects in Ruby
Arrays, Hashes, Objects and Methods
What is the operator called?
The spaceship operator
Where does Rails look to find the current layout?
Rails first looks for a file in the app/views/layouts with the same base name as the controller
What does the following method do:
redirect_to
Tells the browser to send a new request for a different URL
What are the five types of variables in Ruby?
Local, Instance, Class, Constants and Global
What is the blueprint from which individual objects are created?
A class
What does IRb stand for?
Interactive Ruby
What is IRb?
A shell for experimentation in which you can immediately view expression results, line by line.
What is an identifier?
Identifiers are names of variables, constants, and methods and are case sensitive.
What are variables?
They are memory locations which holds any data to be used by any program.
What is a Global variable?
A variable that is accessible in every scope
What is a Class variable?
A variable defined in a class of which a single copy exists, regardless of how many instances of the class exist