Created
December 23, 2014 18:02
-
-
Save rohanthewiz/640e4be57d7cbe1ee7b4 to your computer and use it in GitHub Desktop.
Example of East Oriented programming via Method Chaining
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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