Array.fill returns Unit since it's an in-place array operation.
Revised #KT-4760
This commit is contained in:
@@ -409,73 +409,64 @@ public fun <T> Array<T>.copyOfRange(from: Int, to: Int): Array<T> {
|
|||||||
/**
|
/**
|
||||||
* Fills original array with the provided value.
|
* Fills original array with the provided value.
|
||||||
*/
|
*/
|
||||||
public fun BooleanArray.fill(element: Boolean): BooleanArray {
|
public fun BooleanArray.fill(element: Boolean): Unit {
|
||||||
Arrays.fill(this, element)
|
Arrays.fill(this, element)
|
||||||
return this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills original array with the provided value.
|
* Fills original array with the provided value.
|
||||||
*/
|
*/
|
||||||
public fun ByteArray.fill(element: Byte): ByteArray {
|
public fun ByteArray.fill(element: Byte): Unit {
|
||||||
Arrays.fill(this, element)
|
Arrays.fill(this, element)
|
||||||
return this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills original array with the provided value.
|
* Fills original array with the provided value.
|
||||||
*/
|
*/
|
||||||
public fun CharArray.fill(element: Char): CharArray {
|
public fun CharArray.fill(element: Char): Unit {
|
||||||
Arrays.fill(this, element)
|
Arrays.fill(this, element)
|
||||||
return this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills original array with the provided value.
|
* Fills original array with the provided value.
|
||||||
*/
|
*/
|
||||||
public fun DoubleArray.fill(element: Double): DoubleArray {
|
public fun DoubleArray.fill(element: Double): Unit {
|
||||||
Arrays.fill(this, element)
|
Arrays.fill(this, element)
|
||||||
return this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills original array with the provided value.
|
* Fills original array with the provided value.
|
||||||
*/
|
*/
|
||||||
public fun FloatArray.fill(element: Float): FloatArray {
|
public fun FloatArray.fill(element: Float): Unit {
|
||||||
Arrays.fill(this, element)
|
Arrays.fill(this, element)
|
||||||
return this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills original array with the provided value.
|
* Fills original array with the provided value.
|
||||||
*/
|
*/
|
||||||
public fun IntArray.fill(element: Int): IntArray {
|
public fun IntArray.fill(element: Int): Unit {
|
||||||
Arrays.fill(this, element)
|
Arrays.fill(this, element)
|
||||||
return this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills original array with the provided value.
|
* Fills original array with the provided value.
|
||||||
*/
|
*/
|
||||||
public fun LongArray.fill(element: Long): LongArray {
|
public fun LongArray.fill(element: Long): Unit {
|
||||||
Arrays.fill(this, element)
|
Arrays.fill(this, element)
|
||||||
return this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills original array with the provided value.
|
* Fills original array with the provided value.
|
||||||
*/
|
*/
|
||||||
public fun ShortArray.fill(element: Short): ShortArray {
|
public fun ShortArray.fill(element: Short): Unit {
|
||||||
Arrays.fill(this, element)
|
Arrays.fill(this, element)
|
||||||
return this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills original array with the provided value.
|
* Fills original array with the provided value.
|
||||||
*/
|
*/
|
||||||
public fun <T> Array<T>.fill(element: T): Array<T> {
|
public fun <T> Array<T>.fill(element: T): Unit {
|
||||||
Arrays.fill(this, element)
|
Arrays.fill(this, element)
|
||||||
return this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -86,11 +86,10 @@ fun specialJVM(): List<GenericFunction> {
|
|||||||
templates add f("fill(element: T)") {
|
templates add f("fill(element: T)") {
|
||||||
only(InvariantArraysOfObjects, ArraysOfPrimitives)
|
only(InvariantArraysOfObjects, ArraysOfPrimitives)
|
||||||
doc { "Fills original array with the provided value." }
|
doc { "Fills original array with the provided value." }
|
||||||
returns { "SELF" }
|
returns { "Unit" }
|
||||||
body {
|
body {
|
||||||
"""
|
"""
|
||||||
Arrays.fill(this, element)
|
Arrays.fill(this, element)
|
||||||
return this
|
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user