Skip to content

Instantly share code, notes, and snippets.

@hseritt
Created June 1, 2019 03:09
Show Gist options
  • Save hseritt/40feb28eaf864a4b711eb3c747caf6d3 to your computer and use it in GitHub Desktop.
Save hseritt/40feb28eaf864a4b711eb3c747caf6d3 to your computer and use it in GitHub Desktop.
If I run example.py, I get "8" ... if run example.rb I get error: Traceback (most recent call last): 1: from ./example1.rb:12:in `<main>' ./example1.rb:3:in `times2': wrong number of arguments (given 0, expected 1) (ArgumentError)
#!/usr/bin/env python
def times2(num):
return num * 2
def add(num1, num2, fn=None):
sum = num1 + num2
return fn(sum)
answer = add(1, 3, times2)
print(answer)
#!/usr/bin/env ruby
def times2(num)
return num * 2
end
def add(num1, num2, fn=nil)
sum = num1 + num2
return fn sum
end
answer = add(1, 3, times2)
puts answer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment