Basic terms in Ruby....
• Class: A class is a definition of a concept in an object-oriented language such as
Ruby. We created classes called Pet, Dog, Cat, Snake, and Person. Classes can inherit
features from other classes, but still have unique features of their own.
• Object: An object is a single instance of a class (or, as can be the case, an instance of
a class itself). An object of class Person is a single person. An object of class Dog is a
single dog. Think of objects as real-life objects. A class is the classification, whereas
an object is the actual object or “thing” itself.
• Object orientation: Object orientation is the approach of using classes and objects
to model real-world concepts in a programming language, such as Ruby.
• Variable: In Ruby, a variable is a placeholder for a single object, which may be a
number, string, list, or an instance of a class that you have defined, such as, in this
chapter, a Pet.
• Method: A method represents a set of code (containing multiple commands and
statements) within a class and/or an object. For example, our Dog class objects had
a bark method that printed “Woof!” to the screen. Methods can also be directly
linked to classes, as with fred = Person.new, where new is a method that creates a
new object based upon the Person class. Methods can also accept data—known as
arguments or parameters—included in parentheses after the method name, as
with puts("Test").
• Arguments/parameters: The data passed to methods in parentheses (or, as in some
cases, following the method name without parentheses, as in puts "Test").
• Kernel: Some methods don’t require a class name to be usable, such as puts. These
are usually built-in, common methods that don’t have an obvious connection to
any classes. Many of these methods are included in Ruby’s Kernel module, a module
that provides functions that work from anywhere within Ruby code without
being explicitly referred to.
Ruby. We created classes called Pet, Dog, Cat, Snake, and Person. Classes can inherit
features from other classes, but still have unique features of their own.
• Object: An object is a single instance of a class (or, as can be the case, an instance of
a class itself). An object of class Person is a single person. An object of class Dog is a
single dog. Think of objects as real-life objects. A class is the classification, whereas
an object is the actual object or “thing” itself.
• Object orientation: Object orientation is the approach of using classes and objects
to model real-world concepts in a programming language, such as Ruby.
• Variable: In Ruby, a variable is a placeholder for a single object, which may be a
number, string, list, or an instance of a class that you have defined, such as, in this
chapter, a Pet.
• Method: A method represents a set of code (containing multiple commands and
statements) within a class and/or an object. For example, our Dog class objects had
a bark method that printed “Woof!” to the screen. Methods can also be directly
linked to classes, as with fred = Person.new, where new is a method that creates a
new object based upon the Person class. Methods can also accept data—known as
arguments or parameters—included in parentheses after the method name, as
with puts("Test").
• Arguments/parameters: The data passed to methods in parentheses (or, as in some
cases, following the method name without parentheses, as in puts "Test").
• Kernel: Some methods don’t require a class name to be usable, such as puts. These
are usually built-in, common methods that don’t have an obvious connection to
any classes. Many of these methods are included in Ruby’s Kernel module, a module
that provides functions that work from anywhere within Ruby code without
being explicitly referred to.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home