# ====================================================================================
# Functions
# ====================================================================================

# The last statement of a function is implictly returned. Parenthesis for functions
# are optional as long as the statement can be envaluated disambiguously.

puts ''
puts ''
puts '================================'
puts ''

# ====================================================================================
# Functions single parameter
# ====================================================================================

def add_one_to n
  n + 1
end

puts add_one_to(3)

# ====================================================================================
# Functions with default parameter values
# ====================================================================================

def function_with_default_value v = 10
  v * 10
end

puts "passing three: #{function_with_default_value(3)}"
puts "passing nil: #{function_with_default_value}"

# ====================================================================================
# Nil default parameter value and ||= operator.
# ====================================================================================

def function_with_nil_default_with_local a = nil
  result   = a
  result ||= "or equal operator was exected and set a default value"
end

puts "passing 'hi': #{function_with_nil_default_with_local 'hi'}"
puts "passing nil: #{function_with_nil_default_with_local}"

puts ''
puts '================================'
puts ''
puts ''
