[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

is_defined?

Eko Budi Setiyo

2/28/2005 3:11:00 AM

Any body now how to do some thing like this in ruby

is_class_defined?
is_module_defined?
is_methode_defined?

regards
Eko



6 Answers

Austin Ziegler

2/28/2005 3:24:00 AM

0

On Mon, 28 Feb 2005 12:11:21 +0900, Eko Budi Setiyo
<contact_us@haltebis.com> wrote:
> Any body now how to do some thing like this in ruby
>
> is_class_defined?
> is_module_defined?
> is_methode_defined?

def foo; end
defined?(foo) # => "method"

Both of the following return "constant."

class Foo; end
module Bar; end
defined?(Foo) # => "constant"
defined?(Bar) # => "constant"

-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca


Navindra Umanee

2/28/2005 3:34:00 AM

0

Austin Ziegler <halostatue@gmail.com> wrote:
> def foo; end
> defined?(foo) # => "method"
>
> Both of the following return "constant."
>
> class Foo; end
> module Bar; end
> defined?(Foo) # => "constant"
> defined?(Bar) # => "constant"

Out of curiosity, why doesn't this work:

irb(main):014:0> defined? defined?
SyntaxError: compile error
(irb):14: syntax error
from (irb):14

Cheers,
Navin.


Austin Ziegler

2/28/2005 3:37:00 AM

0

On Mon, 28 Feb 2005 12:33:35 +0900, Navindra Umanee
<navindra@cs.mcgill.ca> wrote:
> Out of curiosity, why doesn't this work:
>
> irb(main):014:0> defined? defined?
> SyntaxError: compile error
> (irb):14: syntax error
> from (irb):14

defined? may be a keyword. I don't recall for certain.

-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca


Eko Budi Setiyo

2/28/2005 5:21:00 AM

0

Austin Ziegler wrote:

>On Mon, 28 Feb 2005 12:11:21 +0900, Eko Budi Setiyo
><contact_us@haltebis.com> wrote:
>
>
>>Any body now how to do some thing like this in ruby
>>
>>is_class_defined?
>>is_module_defined?
>>is_methode_defined?
>>
>>
>
> def foo; end
> defined?(foo) # => "method"
>
>Both of the following return "constant."
>
> class Foo; end
> module Bar; end
> defined?(Foo) # => "constant"
> defined?(Bar) # => "constant"
>
>-austin
>
>
Thanks




Minero Aoki

2/28/2005 6:00:00 AM

0

Bertram Scharpf

2/28/2005 8:35:00 AM

0

Hi,

Am Montag, 28. Feb 2005, 12:33:35 +0900 schrieb Navindra Umanee:
> Austin Ziegler <halostatue@gmail.com> wrote:
> > def foo; end
> > defined?(foo) # => "method"
>
> Out of curiosity, why doesn't this work:
>
> irb(main):014:0> defined? defined?
> SyntaxError: compile error
> (irb):14: syntax error
> from (irb):14

`defined?' is an operator, not a method.

This is confusing as `Module#method_defined?' and
`Module#const_defined?' are methods.

Bertram


--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-...