Skip to content

Instantly share code, notes, and snippets.

@surrealdetective
Created June 11, 2013 04:07
Show Gist options
  • Save surrealdetective/5754420 to your computer and use it in GitHub Desktop.
Save surrealdetective/5754420 to your computer and use it in GitHub Desktop.
method chaining to the meaning of life
puts "what is the meaning of life?".slice(12, 7)
# => meaning
puts "what is the meaning of life?".slice(12, 7).concat(" can the universe really provide? ")
# => meaning can the universe really provide?
puts "what is the meaning of life?".slice(12, 7).concat(" can the universe really provide? ").reverse
# => ?edivorp yllaer esrevinu eht nac gninaem
puts "what is the meaning of life?".slice(12, 7).concat(" can the universe really provide? ").reverse.strip
# => ?edivorp yllaer esrevinu eht nac gninaem
puts "what is the meaning of life?".slice(12, 7).concat(" can the universe really provide? ").reverse.chomp.length
42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment