Skip to content

Instantly share code, notes, and snippets.

@jwieringa
Created October 18, 2013 14:00
Show Gist options
  • Save jwieringa/7041960 to your computer and use it in GitHub Desktop.
Save jwieringa/7041960 to your computer and use it in GitHub Desktop.
def max(x, y)
x > y ? x : y
end
def max_or_zero(x, y)
max(0, max(x, y))
end
@cupakromer
Copy link

def max_or_zero(*args)
  return 0 if args.empty?
  max(args.pop, max_or_zero(*args))
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment