------=_Part_901_5991014.1143646844489
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
J> Robert Dober was kind enough to point out that RDoc may have led me
J> astray here. You can call Kernel methods like class methods and they
J> do not show up in the list of instance_methods(). They are mixed
J> into Object though, right? Can someone clue me in here?
a global function is a Kernel module function : this mean that it's a
*private* method (this is why #instance_methods don't display it) and a
public singleton method
moulon% ruby -e 'module M def f() end; module_function :f end; p
M.instance_methods'
[]
moulon%
moulon% ruby -e 'module M def f() end; module_function :f end; p
M.private_instance_methods'
["f"]
moulon%
moulon% ruby -e 'module M def f() end; module_function :f end; p
M.singleton_methods'
["f"]
moulon%
Guy Decoux
I knew I was wrong all the time, ty for showing me
here we go
irb(main):015:0> Kernel.private_instance_methods
=3D> ["gets", "catch", "String", "`", "sleep", "getc", "warn", "gsub!",
"iterator?", "sprintf", "remove_instance_variable", "Integer", "split",
"putc", "abort", "chop", "lambda", "initialize_copy", "srand", "p",
"local_variables", "singleton_method_removed", "printf", "caller",
"require", "sub", "eval", "set_trace_func", "callcc", "binding", "readline"=
,
"throw", "Array", "chop!", "syscall", "raise", "autoload?", "format",
"trace_var", "exit!", "block_given?", "trap", "Float", "at_exit", "puts",
"loop", "sub!", "chomp", "system", "singleton_method_undefined",
"method_missing", "scan", "select", "rand", "exit", "print", "fork", "gsub"=
,
"exec", "autoload", "singleton_method_added", "global_variables",
"readlines", "proc", "fail", "chomp!", "open", "untrace_var", "test",
"load"]
irb(main):016:0> Kernel.private_instance_methods.include?("puts")
=3D> true
Cheers
Robert
--
Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui
concerne l'univers, je n'en ai pas acquis la certitude absolue.
- Albert Einstein
------=_Part_901_5991014.1143646844489--