count array's length in Ruby
Code snippet on how to count array's length in Ruby
arr = [1,2,3,4]
arr_length = arr.length
puts arr_length
This code will count the length of an array in Ruby. The first line creates an array called “arr” with the numbers 1 through 4. The second line assigns a variable called “arr_length” to the length of the array. Finally, the last line prints the length of the array (4) to the console.