From 73ef8e13ff1f84f99794e6b5eff9dac3492c0e62 Mon Sep 17 00:00:00 2001 From: kindlich Date: Fri, 6 Sep 2024 21:20:34 +0200 Subject: [PATCH] refactor: Use implicit ctor for lists --- src/main/zencode/stdlib/src/Arrays.zs | 7 ------- src/main/zencode/stdlib/src/List.zs | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/zencode/stdlib/src/Arrays.zs b/src/main/zencode/stdlib/src/Arrays.zs index 7bac917..3992b22 100644 --- a/src/main/zencode/stdlib/src/Arrays.zs +++ b/src/main/zencode/stdlib/src/Arrays.zs @@ -176,11 +176,4 @@ public expand T[] { result[key(value)] = value; return result; } - - public implicit as List { - var result = new List(); - for value in this - result.add(value); - return result; - } } diff --git a/src/main/zencode/stdlib/src/List.zs b/src/main/zencode/stdlib/src/List.zs index b69b25b..1e44962 100644 --- a/src/main/zencode/stdlib/src/List.zs +++ b/src/main/zencode/stdlib/src/List.zs @@ -2,6 +2,13 @@ public class List { [Native("constructor")] public this() {} + + public implicit this(array as T[]) { + var result = new List(); + for value in array + result.add(value); + return result; + } [Native("add")] public add(value as T) as void;