Last active
August 29, 2015 14:06
-
-
Save sharmaabhinav/071cb1d20492c5005e6f to your computer and use it in GitHub Desktop.
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 OperatorDemo | |
| attr_accessor :name | |
| def initialize(params = {}) | |
| self.name = params.fetch(:name, "abhinav") | |
| end | |
| def +(name2) | |
| params = { name: name + " " + name2.name } | |
| obj = create_obj(params) | |
| return obj | |
| end | |
| def create_obj(params) | |
| OperatorDemo.new(params) | |
| end | |
| def to_s | |
| name | |
| end | |
| end | |
| x = OperatorDemo.new | |
| y = OperatorDemo.new({ name: "sharma" }) | |
| z = x + y | |
| puts z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment