p "========================Traverse first and last element of a matrix's sub arrays==========================="

matrix = [[10,2,5,20], [30,15,25,6], [1,3,11,6]]

p matrix.each{|arr| arr[0], arr[-1] = arr[-1], arr[0]}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: