summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-11-05 14:12:42 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-11-05 14:29:25 +0900
commitafba74ff5054a5a2a6d5201fef6fd11e7b520b74 (patch)
treea996dc40d11e005655005b835d480554e0f2e02e
parentaa4d8e9a2b41e578659247e4da3a881a12853999 (diff)
downloadmruby-afba74ff5054a5a2a6d5201fef6fd11e7b520b74.tar.gz
mruby-afba74ff5054a5a2a6d5201fef6fd11e7b520b74.zip
Add `Array.new([1,2,3])` initialization.
-rw-r--r--mrblib/array.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/mrblib/array.rb b/mrblib/array.rb
index 8586fbc39..e248914e8 100644
--- a/mrblib/array.rb
+++ b/mrblib/array.rb
@@ -66,6 +66,10 @@ class Array
#
# ISO 15.2.12.5.15
def initialize(size=0, obj=nil, &block)
+ if size.is_a?(Array) && obj==nil && block == nil
+ self.replace(size)
+ return self
+ end
size = size.__to_int
raise ArgumentError, "negative array size" if size < 0