Ruby 2.5 added a new method named yield_self. It yields the receiver to the given block and returns output of the last statement in the block. 1irb> "Hello".yield_self { |str| str + " World" } 2 => "Hello World"Copy How is it different from try in Rails ? Without a method argument try behaves similar to yield_self. It would yield to the given block unless the receiver is nil and returns the output
![Ruby 2.5 added yield_self | BigBinary Blog](https://cdn-ak-scissors.b.st-hatena.com/image/square/df7dcf3e382d2d4b018ba79fc6642260e3fa7070/height=288;version=1;width=512/https%3A%2F%2Fres.cloudinary.com%2Fdpc4i4bdx%2Fimage%2Fupload%2Fbigbinary_blogs%2Fdefault_blog_image.png)