backport_yield_self is the backport of Kernel#yield_self
in Ruby 2.5 to older Ruby versions.
The best way is to use Ruby 2.5 or later. Because you can use original yield_self
method and so on.
Installation
Add these lines to your application's Gemfile:
gem 'backport_yield_self'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install backport_yield_self
And require it as:
require 'backport_yield_self'
Synopsis
'my string'.yield_self {|s| s.upcase } #=> "MY STRING"
3.next.yield_self {|x| x**x }.to_s #=> "256"
Supported Ruby versions
- Ruby 2.2
- Ruby 2.3
- Ruby 2.4
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
License
backport_yield_self is released under the MIT License.
Get the original codes
- Kernel#yield_self https://github.com/ruby/ruby/commit/cec0668
Special Thanks
- Ruby Development Team