Everything in Ruby is an object, is it?

Sep 11, 2007 19:47


irb(main):001:0> def fred(x); x + 1; end
nil
irb(main):002:0> fred.methods
ArgumentError: wrong # of arguments(0 for 1)
from (irb):2:in `fred'
from (irb):2
irb(main):003:0> 1.+.methods
ArgumentError: wrong # of arguments(0 for 1)
from (irb):3:in `+'
from (irb):3
irb(main):004:0> {|x| x+1}.methods
SyntaxError: compile error
(irb):4: parse error
{|x| x+1}.methods
^
(irb):4: parse error
{|x| x+1}.methods
^
from (irb):4
irb(main):005:0> lambda {|x| x+1}.methods
["call", "==", "[]", "arity", "to_s", "dup", "eql?", "protected_methods",
"frozen?", "===", "respond_to?", "class", "kind_of?", "__send__", "nil?",
"instance_eval", "public_methods", "untaint", "__id__", "display",
"inspect", "taint", "hash", "=~", "private_methods", "to_a", "is_a?",
"clone", "equal?", "singleton_methods", "freeze", "type", "instance_of?",
"send", "methods", "method", "tainted?", "instance_variables", "id",
"extend"] In unrelated news, Happy birthday stronae!

And does anyone if there's a portable way of finding the arity of a function in Scheme?

lisp, computers, programming, type systems, beware the geek, ruby

Previous post Next post
Up