I have four questions. I hope you can help me. Good idea questions, maybe this will help others. Thanks in advance.
Question 1) I know that if you don't write anything to storage, then That function is free of gas. right? i can even make public view function and make thouthands for loop, but since there's no reason to distribute this change to other nodes, it must be free even though for loop is big and even though i am making new variables in memory in that function. Is my idea right?
Question 2) I made the public view function, but in that function I wrote something like writing a number in an array and then after writing it , i returned new added element from that array. I touched the storage, I wrote it there. but because of I named my function "view" , it didn't ask me to put gas in metamask. there was no metamask needed at all, even though i wrote in storage. why? My opinion is that It works for me, but not for others and it wouldn't propagate across the nodes.
Question 3) Everyone says you can't return dynamic arrays from functions. Let's take uint[] array. It's dynamic, but I can still return it. then what do people mean? I know i can't return multidimensional array and structs of array. but I can return uint[].
Question 4) I know that If there's some data in storage for example uint[] x
. now If I write in a function something like that : uint[] memory mytest = x;
That x data that was in storage gets copied into memory. Am I right? If not? why? if yes, does it work the way around? to copy from memory to storage? But i don't think so, because you can't write anything in storage later unless you specify at run time.