so 1.class will give Fixnum...
but when i define a method
def foo
puts "ha"
end
how can i invoke
foo.class
as it is taking what foo returns... as then invoke class on that.
···
--
Posted via http://www.ruby-forum.com/.
so 1.class will give Fixnum...
but when i define a method
def foo
puts "ha"
end
how can i invoke
foo.class
as it is taking what foo returns... as then invoke class on that.
--
Posted via http://www.ruby-forum.com/.
so 1.class will give Fixnum...
but when i define a method
def foo
puts "ha"
endhow can i invoke
foo.class
>> def foo; end
=> nil
>> method(:foo).class
=> Method
Hope that helps.
James Edward Gray II
On Sep 19, 2007, at 8:19 AM, SpringFlowers AutumnMoon wrote:
SpringFlowers AutumnMoon wrote:
so 1.class will give Fixnum...
but when i define a method
def foo
puts "ha"
endhow can i invoke
foo.class
as it is taking what foo returns... as then invoke class on that.
becouse foo returns what puts returns and it's nil, and nil have NilClass
you have to understand that in ruby EVERYTHING returns value (even if it's nil) and everything is object (even nil)