Using this tutorial, we are going to run the script Ruby Program to Create a User-Defined Function Without Argument but Return a Value. Below you will find the possibilities for doing the task using this tutorial.

Ruby Program to Create a User-Defined Function Without Argument but Return a Value
# Ruby program to create a user define function
# without argument but return a value
def AddNum()
print "Enter number1: ";
num1 = gets.chomp.to_i;
print "Enter number2: ";
num2 = gets.chomp.to_i;
add = num1 + num2;
return add;
end
print "Addition is: ",AddNum();
Enter number1: 12
Enter number2: 45
Addition is: 57
Final Words
I hope this article is a Ruby Program to Create a User-Defined Function Without Argument but Return a Value Let me know in the comments section if you have any issues.