HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/gems/ruby-3.0.2/doc/activesupport-6.1.4.1/ri/Array/wrap-c.ri
U:RDoc::AnyMethod[iI"	wrap:ETI"Array::wrap;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph;	[I"RWraps its argument in an array unless it is already an array (or array-like).;To:RDoc::Markup::BlankLineo;
;	[I"Specifically:;T@o:RDoc::Markup::List:
@type:BULLET:@items[o:RDoc::Markup::ListItem:@label0;	[o;
;	[I"9If the argument is +nil+ an empty array is returned.;To;;0;	[o;
;	[I"\Otherwise, if the argument responds to +to_ary+ it is invoked, and its result returned.;To;;0;	[o;
;	[I"IOtherwise, returns an array with the argument as its single element.;T@o:RDoc::Markup::Verbatim;	[I"#Array.wrap(nil)       # => []
;TI"*Array.wrap([1, 2, 3]) # => [1, 2, 3]
;TI"$Array.wrap(0)         # => [0]
;T:@format0o;
;	[I"`This method is similar in purpose to <tt>Kernel#Array</tt>, but there are some differences:;T@o;;
;;[o;;0;	[o;
;	[I"WIf the argument responds to +to_ary+ the method is invoked. <tt>Kernel#Array</tt> ;TI"\moves on to try +to_a+ if the returned value is +nil+, but <tt>Array.wrap</tt> returns ;TI"Aan array with the argument as its single element right away.;To;;0;	[o;
;	[I"gIf the returned value from +to_ary+ is neither +nil+ nor an +Array+ object, <tt>Kernel#Array</tt> ;TI"Xraises an exception, while <tt>Array.wrap</tt> does not, it just returns the value.;To;;0;	[o;
;	[I"[It does not call +to_a+ on the argument, if the argument does not respond to +to_ary+ ;TI"Ait returns an array with the argument as its single element.;T@o;
;	[I">The last point is easily explained with some enumerables:;T@o;;	[I"/Array(foo: :bar)      # => [[:foo, :bar]]
;TI"/Array.wrap(foo: :bar) # => [{:foo=>:bar}]
;T;0o;
;	[I"?There's also a related idiom that uses the splat operator:;T@o;;	[I"[*object]
;T;0o;
;	[I"Xwhich returns <tt>[]</tt> for +nil+, but calls to <tt>Array(object)</tt> otherwise.;T@o;
;	[I"@The differences with <tt>Kernel#Array</tt> explained above ;TI"+apply to the rest of <tt>object</tt>s.;T:
@fileI".lib/active_support/core_ext/array/wrap.rb;T:0@omit_headings_from_table_of_contents_below000[I"
(object);T@TFI"
Array;TcRDoc::NormalClass00