ruby functions code example
Example 1: ruby function
def double(x)
x * 2
end
Example 2: ruby method
def print_args(arg1,ar2)
puts arg1
puts arg2
end
Example 3: functions in ruby
# functions in ruby
def foo()
# function body
end
def double(x)
x * 2
end
def print_args(arg1,ar2)
puts arg1
puts arg2
end
# functions in ruby
def foo()
# function body
end