what is 6[i] ?
6[1]=1 but 6[7]=0 # would expect nils...

Why would you?

6.class #=> Fixnum

and Fixnum has a # method that is documented.

What do the results of z[3][1][0] or z[3][1][1] mean???
( z[3][1] works as expected )

And please, when you post questions like the above (from your
initial post), then 1. include the results in the post, so that
we know what you are talking about, and 2. state what your
expectations are resp. what surprises you about the result.

There's no easy way to "plant" a value, though; but nothing is stopping you
making your own:

class Array

···

On 9 April 2016 at 21:46, A Berger <aberger7890@gmail.com> wrote:

Hi
Am 09.04.2016 11:49 schrieb "Matthew Kerwin" <matthew@kerwin.net.au>:
>
> Hi again,
>
> These are some... strange questions.
>
> On 9 April 2016 at 19:39, A Berger <aberger7890@gmail.com> wrote:
>>
>> Hi
>> I have an array (maybe random) of x=9 rows, y=3 columns
>> z= [[0, 9, 1], [1, 8, 2], [2, 7, 3], [3, 6, 4], [4, 5, 5], [5, 4, 6],
[6, 3, 7], [7, 2, 8], [8, 1, 9]]
>>
>> Is there any (existing) function for (easy) accessing/setting fields
like "z(3,1)" specifying the position for z[3][1] ?
>
> Aside from z[3][1] ?

z(3,1,7,8,9,1,2,3,4,5) is much easier to type than having around each
index (specially on a non-us keyboard)
Seems there is no such method.

##
# Plant an element into a multi-dimensional (nested) array.
# The opposite of #dig
#
# e.g.:
#
# a = [[1,2],[3,4]]
# a.plant(0,1,9)
# => a == [[1,9],[3,4]]
#
def plant(*args)
value = args.pop
final = args.pop
ary = self
args.each do |i|
# FIXME: raise error or create ary[i] if out of bounds
ary = ary[i]
end
ary[final] = value
end
end

*For Matrix*, there's this:

z[3, 1] #=> 6

or this alias:

z.element(3, 1) #=> 6

or this one:

z.component(3, 1)

These are used to read a value at a position (like Array#dig). See below
for my thoughts on overwriting a value in a Matrix.
This all comes straight from the documentation. (I didn't even know
Matrix/Vector existed before you posted this.)

>> What do the results of z[3][1][0] or z[3][1][1] mean???
>> ( z[3][1] works as expected )
>
> If z[3][1] == 6, then z[3][1][0] == 6[0], which is nonsense.

I mean, what does " z[3][1][0] " (one index more than available) do? (to
give only one example)
I dont understand how the produced result is made.

>> How can I set (change) only one element of a matrix ?
>> I think + (0....0 newValue-oldValue 0...0) is not what is intended...
>
> z[3][1] = 7

I meant for a MATRIX (class). But the problem is solved (using array).

Oh, I see. It's customary to capitalise the first letter of class names,
just as they're written in code (e.g. "Matrix") -- when you originally
wrote "matrix" in all lowercase I thought you meant the mathematical
construct (often represented by nested arrays), and then typing in ALL CAPS
made it seem like you were just yelling the same word louder. The
documentation for Matrix is here:

By the looks of it a Matrix is immutable, so it's probably best to use
Arrays if you want to modify values. Matrix also appears to be used for
doing data analysis, not as a simple data structure (so again, probably use
Arrays; at least until the data is stable, then whack it in a Matrix and
analyse away.)

Thank you for the plant!
Thats why I looked at Matrix.
...and arrived at the "Array without accumulating s" loops.
(And thank you for telling me about syntax!)