Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created March 28, 2020 14:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save havenwood/e1e35f9b0bbc4d102ffb6eade5a4992b to your computer and use it in GitHub Desktop.
module TildeCount
refine Enumerable do
alias ~@ count
end
end
using TildeCount
~[]
#=> 0
~{}
#=> 0
module TildeSize
[Array, Hash, Range].each do |sized_class|
refine sized_class do
alias ~@ size
end
end
end
using TildeSize
~[]
#=> 0
~{}
#=> 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment