|
[RUBY] Classes Tutorial
|
|
04-20-2010, 01:45 PM
Post: #1
|
|||
|
|||
|
[RUBY] Classes Tutorial
Classes in Ruby
In object-oriented programming, a class is a construct that is used as a blueprint (or template) to create objects of that class. This blueprint describes the state and behavior that the objects of the class all share. An object of a given class is called an instance of the class. The class that contains (and was used to create) that instance can be considered as the type of that object, e.g. an object instance of the "Fruit" class would be of the type "Fruit". Starting with classes Lets look at the skeleton of a ruby class Code: class P9This is very simple code, and speaks for it self. It constructs a class named P9 code goes in between the constructor and the end statement. Adding Variables A class with class variables Code: class P9A class variable belongs to the class and is a characteristic of a class. Creating Objects Derived From Your Class This is an easy task, especially if you're familiar with C++ Code: class P9Inheritance Code: class P10 < P9#Inherit off of P9Thats the end of this short tutorial, I hope it helped anyone tryingto learn Ruby "Character is determined more by the lack of certain experiences than by those one has had." Friedrich Nietzsche |
|||
|
04-20-2010, 10:48 PM
Post: #2
|
|||
|
|||
|
RE: [RUBY] Classes Tutorial
This is great.
I can see Back_track that you are becoming an Ruby programmer. You can add some more tuts ! There's a fine line between genius and insanity. I have erased this line. Oscar Levant There's a fine line between an administrator and black hat hacker. I have erased this line. Dr DEBCOL |
|||
|
04-21-2010, 05:56 AM
Post: #3
|
|||
|
|||
|
RE: [RUBY] Classes Tutorial
Yeah, I'm now trying to make a chat program in Ruby. But it's confusing me, especially coming from C#. For some reason, Chat was very easy to me in Delphi and C#, this may be a challenge in Ruby.
"Character is determined more by the lack of certain experiences than by those one has had." Friedrich Nietzsche |
|||
|
« Next Oldest | Next Newest »
|





