what is called Methods in Ruby?
As name itself tells definition, a method is so called because it provides a method (that is, ‘a way’) for an object to respond to messages. In OOP terminology, you send a message to an object by asking it to do something. So let’s imagine that you have an object called robot which has a method called greetfriends. See an example below how you would send it a greetfriends message:
Let’s suppose that the greetfriends method looks like this:
puts( “Hi Friends Good morning. Welcome to Gyantoday.com” )
When we send robot a greetfriends message it responds with the greetfriends method and display “Hi Friends Good morning. Welcome to Gyantoday.com”.
In Ruby programming a method is declared with the keyword def followed by a method name which should begin with a lowercase letter. See an example below:
puts( “Welcome to Gyantoday.com” )