Created
September 19, 2014 19:55
-
-
Save aalavandhan/741613afb440a94cf1c4 to your computer and use it in GitHub Desktop.
A simple implementation of Javascript With Operator in ruby,
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 With | |
attr_accessor :object, :result | |
def initialize(object) | |
@object = object | |
@result = nil | |
end | |
def method_missing(method, *args, &block) | |
@result = @object.send(method, *args, &block) | |
self | |
end | |
end | |
def With(object) | |
With.new(object) | |
end | |
With(1).+(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment