Skip to content

Instantly share code, notes, and snippets.

@ethagnawl
Created June 14, 2018 17:44
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 ethagnawl/27ba11bc74e535b1e31bbffc144189bf to your computer and use it in GitHub Desktop.
Save ethagnawl/27ba11bc74e535b1e31bbffc144189bf to your computer and use it in GitHub Desktop.
yield_self
modified_str = "foo"
.yield_self { |str| str.split('') }
.yield_self { |str| str.join('-') }
.yield_self(&:upcase)
.yield_self { |str| "#{str}!" }
puts modified_str # F-O-O!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment