الفرق بين المراجعتين لصفحة: «Kotlin/kotlin.text/toCollection»
< Kotlin | kotlin.text
أنشأ الصفحة ب'<noinclude>{{DISPLAYTITLE: التابع text.toCollection() في لغة Kotlin}}</noinclude> تعيد الدالة <code>toCollection()</code> مصفوفة من ا...' |
لا ملخص تعديل |
||
| سطر 1: | سطر 1: | ||
<noinclude>{{DISPLAYTITLE: التابع text.toCollection() في لغة Kotlin}}</noinclude> | <noinclude>{{DISPLAYTITLE: التابع text.toCollection() في لغة Kotlin}}</noinclude> | ||
تضيف الدالة <code>toCollection()</code> كل حروف [[Kotlin/CharSequence/index|سلسلة الحروف]] التي استٌدعيت عبرها إلى الوسيط المُمرّر <code>destination</code>. | |||
== البنية العامة == | == البنية العامة == | ||
<syntaxhighlight lang="kotlin"> | <syntaxhighlight lang="kotlin"> | ||
fun <C : MutableCollection<in Char>> CharSequence.toCollection( | |||
destination: C | |||
< | ): C | ||
</syntaxhighlight> | |||
destination: | |||
): | |||
</syntaxhighlight> | |||
== القيم المعادة == | == القيم المعادة == | ||
الوسيط المُمرّر <code>destination</code>. | |||
== أمثلة == | == أمثلة == | ||
=== استخدام الدالة <code>toCollection()</code> مع السلاسل النصية === | === استخدام الدالة <code>toCollection()</code> مع السلاسل النصية === | ||
الشيفرة الآتية < | تعرّف الشيفرة الآتية [[Kotlin/String|سلسلة نصية]] باسم <code>str</code> ولائحة حروف باسم <code>list</code>، ثم تستدعي الدالة <code>toCharArray()</code> عبر <code>str</code> وتمرر إليها <code>list</code>، ثم تطبع الناتج:<nowiki/><syntaxhighlight lang="kotlin"> | ||
fun main(args: Array<String>) { | fun main(args: Array<String>) { | ||
val list : MutableList<Char> = mutableListOf() | |||
val str = "wiki.hsoub.com" | val str = "wiki.hsoub.com" | ||
str.toCollection(list) | |||
println(list) // [w, i, k, i, ., h, s, o, u, b, ., c, o, m] | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== انظر أيضًا == | == انظر أيضًا == | ||
* <code>[[Kotlin/text/toUpperCase|toUpperCase()]]</code> : تحوّل الدالة <code>toUpperCase()</code> الحرف أو السلسلة النصية التي استٌدعيت عبرها إلى حالة الأحرف الكبيرة (uppercase). | * <code>[[Kotlin/text/toUpperCase|toUpperCase()]]</code> : تحوّل الدالة <code>toUpperCase()</code> الحرف أو السلسلة النصية التي استٌدعيت عبرها إلى حالة الأحرف الكبيرة (uppercase). | ||
| سطر 50: | سطر 32: | ||
== مصادر == | == مصادر == | ||
* [http://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/to- | * [http://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/to-collection.html صفحة الدالة text.toCollection() في التوثيق الرسميّ للمكتبة القياسيّة في لغة Kotlin.] | ||
[[تصنيف:Kotlin]] | [[تصنيف:Kotlin]] | ||
[[تصنيف:Kotlin Method]] | [[تصنيف:Kotlin Method]] | ||
مراجعة 11:29، 13 يوليو 2018
تضيف الدالة toCollection() كل حروف سلسلة الحروف التي استٌدعيت عبرها إلى الوسيط المُمرّر destination.
البنية العامة
fun <C : MutableCollection<in Char>> CharSequence.toCollection(
destination: C
): C
القيم المعادة
الوسيط المُمرّر destination.
أمثلة
استخدام الدالة toCollection() مع السلاسل النصية
تعرّف الشيفرة الآتية سلسلة نصية باسم str ولائحة حروف باسم list، ثم تستدعي الدالة toCharArray() عبر str وتمرر إليها list، ثم تطبع الناتج:
fun main(args: Array<String>) {
val list : MutableList<Char> = mutableListOf()
val str = "wiki.hsoub.com"
str.toCollection(list)
println(list) // [w, i, k, i, ., h, s, o, u, b, ., c, o, m]
}
انظر أيضًا
toUpperCase() : تحوّل الدالةtoUpperCase() الحرف أو السلسلة النصية التي استٌدعيت عبرها إلى حالة الأحرف الكبيرة (uppercase).
toBigDecimalOrNull(): تحلّل الدالةtoBigDecimalOrNull() السلسلة النصية التي استٌدعيت عبرها وتحوّلها إلى عدد من النوعBigDecimal.toBigDecimal(): تحلّل الدالةtoBigDecimal() السلسلة النصية التي استٌدعيت عبرها وتحوّلها إلى عدد من النوعBigDecimal.
isDefined(): تعيد القيمةtrueفي حال كان الحرف (Unicode code point) الذي استٌدعيت عبره مُعرّفًا في اليونيكود (Unicode).