However, trying to index any elements gives a “no matching setindex”-error. What happens when i declare tuples as an array, and why is it different than directly assigning values upon initialization?
Not sure I understand the question - are you saying what isn’t working is assigning to an index of an element of your array of tuples like
tup_arr = [(1,2), (3,4)]
tup_arr[1][1] = 5
?
This indeed throws a MethodError: no method matching setindex!, but this is unrelated to having an array of arrays and simply due to the fact that tuples are immutable:
It will create a n*m Tuple Array with ‘undefined’ contents. I.e. each element will just be a chunk of memory that has been interpreted as a Tuple{Int, Int}, so the contents will look like random garbage.
The beautiful thing about Julia is that you are not forced to fiddle with types if you don’t want to. In your case, for example, you can create a 2-by-3 array of tuples easily like this: