I have a method that uses transpose, but I do not want to apply this operation if the array has less than 2 dimensions. I am wondering how I can do this in ruby.
so for an array like [1,2] -> it should say 1D
and for an array like [[1,2],[1,2]] it should say 2D
Any help appreciated,
Ted
You could find it recursively:
I know it is a bit crude and there probably someone who is able to make it much nicer, but the general idea is clear.