Why are you calling a Proc an Object when it's clearly a Method?


#1


So this section is all about explaining how and when to use Proc, but you keep calling them objects. They are clearly methods. Would you call a method an object?


Replace this line with your code.


#3

class MyClass
    def someMethod() end
end

myProc = proc {}
myMethod = MyClass.new.method(:someMethod)

puts "Is a proc an object?"
puts myProc.is_a?Object

puts "Is a proc a method?"
puts myProc.is_a?Method

puts "Is a method an object?"
puts myMethod.is_a?Object

output:

Is a proc an object?
true
Is a proc a method?
false
Is a method an object?
true

#4

One of these days I'm going to have to figure this nomenclature out :confused:

Although I did come up with reliable evidence I was right

class MyClass
def someMethod() end
end

myProc = proc {}
myProc = MyClass.new.method(:someMethod)

puts "Is a proc an object?"
puts myProc.is_a?Object

puts "Is a proc a method?"
puts myProc.is_a?Method

puts "Is a method an object?"
puts myMethod.is_a?Object

ouput

Is a proc an object?
true
Is a proc a method?
true
Is a method an object?
true
nil