There are no two separate concepts for methods and functions in Ruby. Some people still use both terms, but, in my opinion, using the “function” when it comes to Ruby is incorrect. There are no executable code fragments that are not defined on objects, because in Ruby there is nothing that is not an object.
As Dan pointed out, there is a way to call methods that make them look like functions, but the underlying thing is still a method. In fact, you can see this in IRB using the method method
.
> def zomg; puts "hi"; end
So, you can see, the zomg
method is an instance method of an Object and is included in the list of objects of private instance methods.
Emily source share