Created
March 17, 2016 14:24
-
-
Save m3talsmith/c828b8fc80436a48a3bb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@lookup = {} | |
def fn name, *arities, callback | |
@lookup["#{name} #{arities}"] = callback | |
end | |
def lookup_fn_by_arities name, *arities | |
@lookup["#{name} #{arities}"] | |
end | |
a = 1 | |
b = 2 | |
c = 3 | |
fn :foo, 1, 2, 3, -> (*local_arities) { | |
puts "foo 1" | |
puts local_arities | |
} | |
fn :foo, a==1, 1, b==2, 2, c==4, -> (*local_arities) { | |
puts "foo 2" | |
puts local_arities | |
} | |
lookup_fn_by_arities(:foo, 1, 2, 3).call(1,2,3) | |
lookup_fn_by_arities(:foo, true, 1, true, 2, false).call(4,5,6) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment