Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Array wrap and splat
def print3(a,b,c)
puts "a: #{a}, b: #{b}, c:#{c}"
end
a = [1,2,3]
b = Array.new(3, 1)
c = Array.new(3) {|i| i*2}
print3(*a)
require 'active_support/core_ext/array'
e = 1
Array
[*x]
Array.wrap
h, *t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment