Skip to content

Instantly share code, notes, and snippets.

@rohanthewiz
Created December 23, 2014 18:02
Show Gist options
  • Save rohanthewiz/640e4be57d7cbe1ee7b4 to your computer and use it in GitHub Desktop.
Save rohanthewiz/640e4be57d7cbe1ee7b4 to your computer and use it in GitHub Desktop.
Example of East Oriented programming via Method Chaining
class Car
def initialize(color, make, model)
@color, @make, @model = color, make, model
# new implicitly returns self
end
def color; puts @color; self; end
def make; puts @make; self; end
def model; puts @model; self; end
end
Car.new('Honda', 'Accord', 'blue').color.make.model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment