Skip to content

Files

Latest commit

 

History

History
24 lines (16 loc) · 607 Bytes

SpreadOperator.md

File metadata and controls

24 lines (16 loc) · 607 Bytes

Pattern: Use of spread operator

Issue: -

Description

Using a spread operator causes a full copy of the array to be created before calling a method. This has a very high performance penalty.

Example of incorrect code:

fun foo(strs: Array<String>) {
    bar(*strs)
}

fun bar(vararg strs: String) {
    strs.forEach { println(it) }
}

Further Reading