Liste des Groupes | Revenir à co vms |
In article <v8o4h8$2ut3$1@dont-email.me>,That rules out Java.
Arne Vajhøj <arne@vajhoej.dk> wrote:On 8/4/2024 8:22 AM, Dan Cross wrote:Designed in this century.Interesting, this has become du jour again in modern languages,>
but those tend to provide access to a `slice` type that provides
a window onto the underly array, and implicitly encodes a
length (and usually a "capacity"). This makes working with
arrays in such languages very convenient.
Different people may have different opinions on what is a modern
language.
But C#, Scala and Kotlin also just allows for passing any lengthBut a lot of the widely used static typed languages does notLike I said, modern languages make this a solved problem.
have any problems with arrays of different lengths as they
are treated as objects.
I don't think so.Like:Java arrays are more like the aforementioned slices.
>
public class FlexArray {
private static void dump(int[] a) {
for(int v : a) {
System.out.printf(" %d", v);
}
System.out.println();
}
public static void main(String[] args) throws Exception {
int[] a1 = { 1 };
int[] a2 = { 1, 2 };
int[] a3 = { 1, 2, 3 };
dump(a1);
dump(a2);
dump(a3);
}
}
Les messages affichés proviennent d'usenet.