Check for index-out-of-bound in elementAt function (KT-30051)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package kotlin.text
|
||||
|
||||
//
|
||||
// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
import kotlin.js.*
|
||||
|
||||
/**
|
||||
* Returns a character at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this char sequence.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
public actual fun CharSequence.elementAt(index: Int): Char {
|
||||
return elementAtOrElse(index) { throw IndexOutOfBoundsException("index: $index, length: $length}") }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user