Creating and Calling a Method : Method Creation « Method « Ruby






Creating and Calling a Method


def greeting
  puts "Hello, pilgrim."
end

# As you already know, you call a method simply by giving its name:

greeting

 








Related examples in the same category

1.A simple definition for a method named hello, created with the keywords def and end
2.define methods that have arguments
3.You can a function with or without parenthesis
4.Call a function for a parameter with or without parenthesis
5.You can call another function based on the return from this funtion call
6.method with ?
7.Define a method to convert Cartesian (x,y) coordinates to Polar
8.Add a new method by add method to Class