A simple definition for a method named hello, created with the keywords def and end : Method Creation « Method « Ruby






A simple definition for a method named hello, created with the keywords def and end


def hello
  puts "Hello, Matz!"
end

hello # => Hello, Matz!

 








Related examples in the same category

1.Creating and Calling a Method
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