Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyClass
- class<<self
- def new(*args)
- ret = if (args.size == 1 && args[0].kind_of?(String))
- obj = allocate
- obj.send(:initialize,*args)
- obj
- else
- false
- end
- end
- end
- def initialize string
- @my_name = string
- end
- end
- puts MyClass.new(123).inspect # => false
- puts MyClass.new("hello").inspect # => #<MyClass:0x101071ed8 @my_name="hello">
Add Comment
Please, Sign In to add comment