الفرق بين المراجعتين لصفحة: «Kotlin/CharSequence/subSequence»
< Kotlin | CharSequence
أنشأ الصفحة ب'<noinclude>{{DISPLAYTITLE: التابع CharSequence.subSequence() في لغة Kotlin}}</noinclude> يعين التابع <code>subSequence()</code> قيمة...' |
لا ملخص تعديل |
||
| سطر 1: | سطر 1: | ||
<noinclude>{{DISPLAYTITLE: التابع CharSequence.subSequence() في لغة Kotlin}}</noinclude> | <noinclude>{{DISPLAYTITLE: التابع CharSequence.subSequence() في لغة Kotlin}}</noinclude> | ||
يعيد التابع <code>subSequence()</code> الجزء المحدد بالوسيطين المُمرّرين <code>startIndex</code> و <code>endIndex</code> من [[Kotlin/CharSequence/index|سلسلة الحروف]] التي استٌدعيت عبرها، | |||
== البنية العامة == | == البنية العامة == | ||
<syntaxhighlight lang="kotlin"> | <syntaxhighlight lang="kotlin"> | ||
abstract | abstract fun subSequence( | ||
startIndex: Int, | |||
</syntaxhighlight> | endIndex: Int | ||
): CharSequence | |||
</syntaxhighlight> | |||
== القيمة المُعادة == | == القيمة المُعادة == | ||
[[Kotlin/CharSequence/index|سلسلة حروف]]. | |||
== أمثلة == | == أمثلة == | ||
=== استخدام <code>subSequence()</code> على سلسلة نصية === | === استخدام <code>subSequence()</code> على سلسلة نصية === | ||
تُنشِئ الشيفرة الآتية [[Kotlin/String|سلسلة نصية]] باسم <code>s</code>، ثم تستدعي <code>subSequence()</code> عبرها:<syntaxhighlight lang="kotlin"> | تُنشِئ الشيفرة الآتية [[Kotlin/String|سلسلة نصية]] باسم <code>s</code>، ثم تستدعي <code>subSequence()</code> عبرها مع تمرير وسيطين، ثم تطبع الناتج:<syntaxhighlight lang="kotlin"> | ||
fun main(args: Array<String>) { | fun main(args: Array<String>) { | ||
val s = " | val s = "hsoubAcademy" | ||
println(s. | println(s.subSequence(3,7)) // ubAc | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| سطر 25: | سطر 26: | ||
== مصادر == | == مصادر == | ||
* [https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/ | * [https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/sub-sequence.html التابع CharSequence.subSequence في التوثيق الرسميّ للمكتبة القياسيّة في لغة Kotlin.] | ||
[[تصنيف:Kotlin]] | [[تصنيف:Kotlin]] | ||
[[تصنيف:Kotlin Method]] | [[تصنيف:Kotlin Method]] | ||
مراجعة 11:07، 3 يوليو 2018
يعيد التابع subSequence() الجزء المحدد بالوسيطين المُمرّرين startIndex و endIndex من سلسلة الحروف التي استٌدعيت عبرها،
البنية العامة
abstract fun subSequence(
startIndex: Int,
endIndex: Int
): CharSequence
القيمة المُعادة
أمثلة
استخدام subSequence() على سلسلة نصية
تُنشِئ الشيفرة الآتية سلسلة نصية باسم s، ثم تستدعي subSequence() عبرها مع تمرير وسيطين، ثم تطبع الناتج:
fun main(args: Array<String>) {
val s = "hsoubAcademy"
println(s.subSequence(3,7)) // ubAc
}
انظر أيضًا
- الخاصيّة
CharSequence.length: تعيد الخاصيةlengthعدد عناصر سلسلة الحروف التي استٌدعيت عبرها.