On Apr 4, 3:19 pm, Jamal Soueidan <jkhaledsouei... / gmail.com> wrote:
> unknown wrote:
> > Yes. And I don't see how it's so surprising given plenty of languages
> > (including PHP) usually have many more keywords than Ruby has (some
> > have less, but they are less common).
>
> They have plenty, but they don't have something like defined?, they have
> functions that act as defined? keyword.
>

So then just tread "defined?" as a function. It's just not a method.

>
>
> > Think about it a moment. Let's say I ask you: "Please send Steve
> > Somename a bunch of flow...
>
> Great example :D I love it :D
>

Thanks :) .

> > This whole "everything is an object" and "variables needn't to be
> > declared" is something di...
>
> Well someone should know her before me, to tell me about her, so
> basically someone knows about her?
>

Yes, but not you, and if you follow the analogy from the examples, in
this case you were Ruby :) .

>
> > Indeed, if a has not been given a value yet, it cannot be "nil" ("nil"
> > *is* a value, and an object), so this will fail.
>
> That made me confused a little bit, How can nil be a class?

It's not a class, it's an object. And like any object, it has a class,
called NilClass.

 and then a
> method in object base class (nil?)
>

"nil?" is a separate method (the question mark is part of the name, so
"nil" and "nil?" refer to different things), which is defined in
Object (what you call the object base class) to return false, and
overridden in NilClass, to return true. Just try it in irb:

a = Object.new
a.nil?
=> false
nil.nil?
=> true

You are actually completely free to define your own class with a nil?
method returning true, although I wouldn't know why you'd want to do
that.

class SomeNilClass
  def nil?
    true
  end
end

a = SomeNilClass.new
a.nil?
=> true

Christophe.