Skip to content

Instantly share code, notes, and snippets.

@chhhris
Created June 10, 2013 22:14
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 chhhris/5752888 to your computer and use it in GitHub Desktop.
Save chhhris/5752888 to your computer and use it in GitHub Desktop.
# Chain at least 5 method calls to an object. Reduce this operation one chain at a time.
puts "rotator dad rotator".reverse.slice(8,3).capitalize.slice(0,0).concat("Father's Day is this weekend.")
# Don't just use the methods below, make up your own chain and try to see if you can do something fun with Ruby like in the example.
puts "rotator dad rotator".reverse
# #=> rotator dad rotator
puts "rotator dad rotator".reverse.slice(8,3)
# #=> dad
puts "rotator dad rotator".reverse.slice(8,3).capitalize
# #=> Dad
puts "rotator dad rotator".reverse.slice(8,3).capitalize.slice(0,0)
# #=>
puts "rotator dad rotator".reverse.slice(8,3).capitalize.slice(0,0).concat("Father's Day is this weekend.")
# #=> Father's Day is this weekend.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment