Created
June 1, 2019 03:09
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment