Skip to content

Instantly share code, notes, and snippets.

@m3talsmith
Created March 17, 2016 14:24
Show Gist options
  • Save m3talsmith/c828b8fc80436a48a3bb to your computer and use it in GitHub Desktop.
Save m3talsmith/c828b8fc80436a48a3bb to your computer and use it in GitHub Desktop.
@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