Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

Ruby | Methods

# Ruby program to illustrate the parameter
# passing to methods
 
#!/usr/bin/ruby
 
# geeks is the method name
# var1 and var2 are the parameters
def geeks (var1 = "GFG", var2 = "G4G")
 
     #  statements to be executed
     puts "First parameter is #{var1}"
     puts "First parameter is #{var2}"
end
 
# calling method with parameters
geeks "GeeksforGeeks", "Sudo"
 
puts ""
 
puts "Without Parameters"
puts ""
 
# calling method without passing parameters
geeks
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #Ruby #Methods
ADD COMMENT
Topic
Name
1+3 =