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:
@@ -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]
|
||||
Reference in New Issue
Block a user