https://github.com/matsadler/implicit_iterator_args
Ruby library that allows you to use _ to retrieve the arguments to a block
https://github.com/matsadler/implicit_iterator_args
Last synced: 3 months ago
JSON representation
Ruby library that allows you to use _ to retrieve the arguments to a block
- Host: GitHub
- URL: https://github.com/matsadler/implicit_iterator_args
- Owner: matsadler
- Created: 2010-04-07T21:26:43.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2010-05-18T12:34:35.000Z (about 15 years ago)
- Last Synced: 2025-01-14T18:06:38.426Z (5 months ago)
- Language: Ruby
- Homepage:
- Size: 89.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.txt
Awesome Lists containing this project
README
Allows you to use _ to retrieve the arguments to a block, eg:
require 'implicit_iterator_args'
class Array
include ImplicitIteratorArgs
end
[1, 2, 3].each {print _} # prints '123'
[1, 2, 3].inject(4) {_ + _} # => 10However this is quite a hack, and isn't recommended for actual use.
Known bugs:
Trying to access the argument with _ from another thread fails, eg:[1, 2, 3].each {Thread.new {print _}.join} # prints 'nilnilnil'