val numbers = arrayOfNulls(5) // 使用值 10 填充数组的索引0-3所有元素 numbers.fill(10, 0, 3) // 填充后的数组: [10, 10, 10, null, null] numbers.forEachIndexed { index, element -> _console.log(index, element) } // 创建一个大小为 5 的字符串数组,并使用 "hello" 填充 val strings = arrayOfNulls(5) strings.fill("hello", 0, 3) // 字符串数组: [hello, hello, hello, null, null] strings.forEachIndexed { index, element -> _console.log(index, element) }