7
Ruby's Array and Array.wrap的区别
source link: http://blog.grayson.org.cn/blog/2019/05/02/ruby-array-and-array-wrap-different
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Ruby's Array and Array.wrap的区别
May 02, 2019
hash = {cgg: 11, cbq: 22}
pry(main)> Array(hash)
[ [ :cgg, 11 ], [ :cbq, 22 ] ]
pry(main)> Array.wrap(hash)
[ { :cgg => 11, :cbq => 22 } ]
Array(nil)
[]
Array(11)
=> [ 11 ]
Array([11])
=>[ 11 ]
Array.wrap(nil) # => []
Array.wrap([1, 2, 3]) # => [1, 2, 3]
Array.wrap(0) # => [0]
ref: https://api.rubyonrails.org/classes/Array.html#method-c-wrap
此文章 短链接: http://dlj.bz/ATzvzI
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK