Skip to content

Instantly share code, notes, and snippets.

@enebo

enebo/funfun.rb Secret

Created June 2, 2022 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enebo/005c4c55ddda58417e143b8accbb354e to your computer and use it in GitHub Desktop.
Save enebo/005c4c55ddda58417e143b8accbb354e to your computer and use it in GitHub Desktop.
def [](a, b, c: 4)
p a, b, c
end
# public :[] # TR messes up visibility
self[1, c: 2] # Errors with arity error
self[1, c: 2] ||= 3 # MAGIC! it works and makes c: 2 bind to variable b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment