To create a 2x3 matrix in Ruby, you can use a nested array.
Here's an example of how to create a 2x3 matrix and then reverse it:
main.rb207 chars9 lines
This code will output:
main.rb12 chars3 lines
The map
method is used to iterate over each row of the matrix and apply the reverse
method to reverse the elements within each row. Finally, the join
method is used to join the elements of each row with a space separator before printing them.
gistlibby LogSnag