Ruby: Define a custom method

We define methods with the word def and close methods with end. In between we write the method body, or the action our method performs.
Let’s look at an example:

def year
 puts "It's 1995!"


Here our def year method outputs “It’s 1995!”. To run our method, we must call it with year. Otherwise it will not execute.
Methods can use parameters. A parameter is an object we pass to our method, of any type. It works like a variable.

def year(current)
  puts "It's #{current}!"


Here our year method takes a numbercurrentas a parameter. It outputs the year 2020 that we pass in.