Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Use implicit ctor for lists #12

Open
wants to merge 1 commit into
base: feature/refactor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/main/zencode/stdlib/src/Arrays.zs
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,4 @@ public expand <T> T[] {
result[key(value)] = value;
return result;
}

public implicit as List<T> {
var result = new List<T>();
for value in this
result.add(value);
return result;
}
}
7 changes: 7 additions & 0 deletions src/main/zencode/stdlib/src/List.zs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
public class List<T> {
[Native("constructor")]
public this() {}

public implicit this(array as T[]) {
var result = new List<T>();
for value in array
result.add(value);
return result;
}

[Native("add")]
public add(value as T) as void;
Expand Down