feat: add List.new(_) and List.filled(_,_) constructors with size and default value

Add two new list constructors to the Wren VM: `List.new(size)` creates a list of given size with null elements, and `List.filled(size, value)` creates a list with all elements initialized to a specified default value. Includes corresponding C primitives `list_newWithSize` and `list_newWithSizeDefault`, registration in `wrenInitializeCore`, and a test file verifying both constructors produce correct counts and element values. Also adds Max Ferguson to AUTHORS.
This commit is contained in:
Bob Nystrom
2016-08-04 05:34:08 +00:00
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.filled(5, 2)
System.print(list2.count) // expect: 5
System.print(list2) // expect: [2, 2, 2, 2, 2]