In the previous lessons we have seen some examples of methods, such as the reverse method for arrays.
A method is a set of statements that perform a specific task.
You can define your own methods to perform your desired tasks.
The def keyword is used to define a method.
The above code defines a method called “say” that performs a simple output operation, printing “Hi”.
Now that we have defined our method, we can call it by including its name in a line of code:
# outputs “Hi”
You can call methods as many times as you need:
CLICK ON THE BUTTON BELOW TO GO TO THE RUBY MAIN COURSE PAGE.
© License: All Rights Reserved
CONTACT HOLLA TECH – LEARN SUPPORT