Home
Ruby
ActiveRecord
Array
CGI
Class
Collections
Database
Date
Design Patterns
Development
File Directory
GUI
Hash
Language Basics
Method
Network
Number
Rails
Range
Reflection
Statement
String
Threads
Time
Tk
Unit Test
Windows Platform
XML
Menu
initialize class « Class « Ruby
Ruby
Class
initialize class
1.
This code starts by creating the Animal class, and then adds a method named initialize:
2.
the code adds an instance variable named @color that stores the color of the animal to the initialize method:
3.
initializes the instance variable @name with the standard initialize method.
4.
Define constructor for a class
5.
Initialize three attributes