feat: add list constructors with size and default value arguments

Implement two new List constructors: `List.new(size)` creates a list of given size initialized to null, and `List.new(size, default)` creates a list with all elements set to the provided default value. Add corresponding C primitives `list_newWithSize` and `list_newWithSizeDefault` in wren_core.c, register them in the core initialization, and include test coverage for both constructors. Also add Max Ferguson to AUTHORS.
This commit is contained in:
root
2016-07-17 02:01:50 +00:00
parent 4d1215697e
commit 89037e397a
3 changed files with 46 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
var list = List.new(5)
System.print(list.count) // expect: 5
System.print(list) // expect: [null, null, null, null, null]
var list2 = List.new(5, 2)
System.print(list2.count) // expect: 5
System.print(list2) // expect: [2, 2, 2, 2, 2]