Method: Class#new
- Defined in:
- lib/source/ruby.rb
#new ⇒ Object
call-seq:
klass.new(args, ...) -> object
Calls allocate to create a new object of class klass, then invokes that object’s initialize method, passing it args.
class Foo
def initialize(a,b)
@a = a
@b = b
end
def values
"a,b: [%s,%s]" % [@a, @b]
end
end
foo = Foo.new(1,2) #=> #<Foo:0x3cc57a>
foo.values #=> "a,b: [1,2]"
1121 1122 1123 1124 1125 |
# File 'lib/source/ruby.rb', line 1121 def new `var result=this.m$allocate()` `this.prototype.m$initialize.apply(result,arguments)` return `result` end |