Chapter 2 Flashcards
What is IRB?
irb stands for “Interactive Ruby.”
Are semicolons needed?
No, unlike other languages like C++
Interger?
Whole Number
Floating point number?
Number with decimal places.
Class?
Is a Blueprint of Obects.
A class is the definition of a single type object.
Classes can inherit features from other classes, but still have unique features of their own.
attr_accessor?
provides attributes for a class.
attr stands for “attribute,” and accessor roughly means “make these attributes accessible to be set and changed at will.”
Object?
Is an instance of a class.
A class is the classification, whereas an object is the actual object or “thing” itself. object is a single thing based on a class. (such as a “Chris” or a “Mrs. Smith”).
Classes can inherit features from other classes, but still have unique features of their own.
Object orinetation?
Object orientation is the approach of using classes and objects to model real-world concepts in a programming language, such as Ruby.
Instance of a class?
is a specific realization of any object
Puts vs Prints?
The difference between print and puts is that puts automatically moves the output cursor to the next line.
Inheritance?
Inheritance allows different classes to relate to one another and group concepts by their similarities.
The < operator, in Classes?
Denotes class is inherited from.
class Cat < Pet
Methods?
They make objects perform actions.
A method represents a set of code (containing multiple commands and statements) within a class and/or an object.
class Dog < Pet
def bark
puts “Woof!”
end
end
In Ruby everything is a class.
Use Puts example.class to find out which class they’re a member of. eg. number is from fixnum.
Kernel Module?
module—a special type of class packed full of standard, commonly used methods, making your code easier to read and write.
puts “Hello, world!”