OneBite.Dev - Coding blog in a bite size

declare a void function without return value in Ruby

Code snippet on how to declare a void function without return value in Ruby

def sample_function()
  # code
end

This code provides an example of how to declare a void function without a return value in Ruby. The declaration begins with the keyword “def” followed by the name of the function “sample_function” and then a set of empty parentheses. The code within the function is contained within the curly braces. This code, in particular, does not contain any code inside the function. Therefore, this function will not return any values when it is called. It simply runs the code within the function and then ends, without returning any values.

ruby