Charles Oliver Nutter wrote:
> kunjaan wrote:
>> What do you mean when you say"Class definitions are executable code".
>> How do classes differ from other OO languages?
>
> I like to say it like this:
>
> Ruby doesn't have class declarations. "Declaring" a class is actually
> just constructing a new Class object and running code against it. All
> classes start out blank and must have methods and instance variables
> added to them at runtime.
In Brand X...
class Foo
# <----- this area can't execute statements
method Bar
# <----- this area can execute statements.
end
end
In Ruby...
class Foo
# <----- this area CAN execute statements
def Bar
# <----- this area can execute statements.
end
end
A class is a block that evaluates from top to bottom, like any other code. Some
other languages allow that too.