Answers for "ruby get haft of array"

0

ruby get haft of array

left,right = a.each_slice( (a.size/2.0).round ).to_a
# Example
a = [1,2,3,4,5]                         # => [1, 2, 3, 4, 5]
a.each_slice( (a.size/2.0).round ).to_a # => [[1, 2, 3], [4, 5]]
Posted by: Guest on January-25-2021

Browse Popular Code Answers by Language