Function like "function_exits"

On Dec 7, 2007 2:49 PM, MonkeeSage [email protected] wrote:

p self.private_methods.include?(“foo”) # => true


Good job :slight_smile:

Posted viahttp://www.ruby-forum.com/.

But you don’t really want that… :wink:

You want respond_to? which Just Works everywhere.
No, it behaves the same, you will get a respond_to?(foo) false at the
main level.
And really, you
probably don’t even want to be asking if a method is defined (depends
on your code), but usually there are better ways of doing things (like
unit testing).

HTH,
Jordan

http://ruby-smalltalk.blogspot.com/


All truth passes through three stages. First, it is ridiculed. Second,
it is violently opposed. Third, it is accepted as being self-evident.
Schopenhauer (attr.)

Robert D. wrote:

On Dec 7, 2007 2:49 PM, MonkeeSage [email protected] wrote:

p self.private_methods.include?(“foo”) # => true


Good job :slight_smile:

Posted viahttp://www.ruby-forum.com/.

But you don’t really want that… :wink:

You want respond_to? which Just Works everywhere.
No, it behaves the same, you will get a respond_to?(foo) false at the
main level.
And really, you
probably don’t even want to be asking if a method is defined (depends
on your code), but usually there are better ways of doing things (like
unit testing).

HTH,
Jordan

http://ruby-smalltalk.blogspot.com/


All truth passes through three stages. First, it is ridiculed. Second,
it is violently opposed. Third, it is accepted as being self-evident.
Schopenhauer (attr.)

To learn ruby, i 'm trying to developpe a batch from php to ruby. I made
classes easely in ruby, and now i’m coding my main script. In this main
script, i don’t want make a main class, just a code ‘procedural’
(step1, step2 …) with some calls of my classes. In this vision, i’am
trying to do same algorythmy, so i have in php a
function_exists()…and, like a good dog, i do the same in ruby;)
I think in PHPOO for coding in Ruby, probably not the very good way, but
it helps me to translate (i made a function print_r;))
I’m not use OnRail yet, i want know ruby first.
Probably i made some mistakes, but it’s just my second day on ruby…and
it seems i like it;)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs