Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Weird behaviour
my int @a = ();
for (1..1000) -> int $item {
my int @b = ($item);
@b.append(@a);
say @a; say @b;
say @a.elems; say @b.elems;
@a := @b;
}
# ...
# ...
# 998
# 999
# [999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 925 924 923 922 921 920 919 918 917 916 915 914 913 912 911 910 909 908 907 906 905 904 903 902 901 900 ...]
# [1000 999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 925 924 923 922 921 920 919 918 917 916 915 914 913 912 911 910 909 908 907 906 905 904 903 902 901 ...]
# 999
# 1000
# OR
# (depending the run)
# ...
# ...
# 2
# 2
# [999 999]
# [999 999]
# 2
# 2
# [1000 1000]
# [1000 1000]
# 2
# 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment