الفرق بين المراجعتين ل"Kotlin/kotlin.text/toList"

من موسوعة حسوب
اذهب إلى التنقل اذهب إلى البحث
(أنشأ الصفحة ب'<noinclude>{{DISPLAYTITLE: التابع text.toList()‎ في لغة Kotlin}}</noinclude> تضيف الدالة <code>toList()</code>‎ كل حروف Kotlin/CharSeque...')
 
سطر 1: سطر 1:
<noinclude>{{DISPLAYTITLE: التابع text.toList()‎ في لغة Kotlin}}</noinclude>
+
تضيف الدالة <code>toList()</code>‎ [[Kotlin/List|لائحة]] تحتوي كل حروف [[Kotlin/CharSequence/index|سلسلة الحروف]]  التي استٌدعيت عبرها.
تضيف الدالة <code>toList()</code>‎ كل حروف [[Kotlin/CharSequence/index|سلسلة الحروف]]  التي استٌدعيت عبرها إلى الوسيط المُمرّر <code>destination</code>.
+
==البنية العامة==
 +
<syntaxhighlight lang="kotlin">
 +
fun CharSequence.toList(): List<Char>  
  
== البنية العامة ==
 
<syntaxhighlight lang="kotlin">
 
fun <C : MutableCollection<in Char>> CharSequence.toCollection(
 
    destination: C
 
): C
 
 
</syntaxhighlight>
 
</syntaxhighlight>
== القيم المعادة ==
+
==القيم المعادة==
الوسيط المُمرّر <code>destination</code>.
+
[[Kotlin/List|لائحة]] من الحروف.
 
+
==أمثلة==
== أمثلة ==
+
===استخدام الدالة <code>toCollection()‎</code> مع السلاسل النصية===
=== استخدام الدالة <code>toList()‎</code> مع السلاسل النصية ===
+
تستدعي الشيفرة الآتية الدالة <code>toCharArray()‎</code> عبر عدة [[Kotlin/String|سلاسل نصية]]، وتطبع الناتج:<syntaxhighlight lang="kotlin">
تعرّف الشيفرة الآتية [[Kotlin/String|سلسلة نصية]] باسم <code>str</code> ولائحة حروف باسم <code>toList</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()
+
    println("Hello, world!".toList()) // [H, e, l, l, o, ,,  , w, o, r, l, d, !]
val str = "wiki.hsoub.com"  
+
    println("Hsoub".toList()) // [H, s, o, u, b]
   
+
    println("114".toList()) // [1, 1, 4]
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/kotlin.text/toDouble|toDouble()]]</code>‎ : تحلّل الدالة <code>toDouble()</code>‎ السلسلة النصية التي استٌدعيت عبرها وتحوّلها إلى عدد من النوع <code>Double</code> وتعيد الناتج.
 +
 
 +
*<code>[[Kotlin/text/toUpperCase|toUpperCase()]]</code>‎ : تحوّل الدالة <code>toUpperCase()</code>‎ الحرف أو السلسلة النصية التي استٌدعيت عبرها إلى حالة الأحرف الكبيرة (uppercase).
  
 
*<code>[[Kotlin/text/isDefined|toBigDecimalOrNull()]]‎</code>: تحلّل الدالة <code>toBigDecimalOrNull()</code>‎ [[Kotlin/String|السلسلة النصية]] التي استٌدعيت عبرها وتحوّلها إلى عدد من النوع <code>BigDecimal</code>.
 
*<code>[[Kotlin/text/isDefined|toBigDecimalOrNull()]]‎</code>: تحلّل الدالة <code>toBigDecimalOrNull()</code>‎ [[Kotlin/String|السلسلة النصية]] التي استٌدعيت عبرها وتحوّلها إلى عدد من النوع <code>BigDecimal</code>.
 
*<code>[[Kotlin/kotlin.text/toBigDecimal|toBigDecimal()]]‎</code>: تحلّل الدالة <code>toBigDecimal()</code>‎ [[Kotlin/String|السلسلة النصية]] التي استٌدعيت عبرها وتحوّلها إلى عدد من النوع <code>BigDecimal</code>.
 
*<code>[[Kotlin/kotlin.text/toBigDecimal|toBigDecimal()]]‎</code>: تحلّل الدالة <code>toBigDecimal()</code>‎ [[Kotlin/String|السلسلة النصية]] التي استٌدعيت عبرها وتحوّلها إلى عدد من النوع <code>BigDecimal</code>.
  
* <code>[[Kotlin/text/isDefined|isDefined()]]‎</code>: تعيد القيمة <code>true</code> في حال كان الحرف (Unicode code point) الذي استٌدعيت عبره مُعرّفًا في اليونيكود (Unicode).
+
*<code>[[Kotlin/text/isDefined|isDefined()]]‎</code>: تعيد القيمة <code>true</code> في حال كان الحرف (Unicode code point) الذي استٌدعيت عبره مُعرّفًا في اليونيكود (Unicode).
 
+
==مصادر==
== مصادر ==
+
<span> </span>
* [http://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/to-collection.html صفحة الدالة text.toList()‎ في التوثيق الرسميّ للمكتبة القياسيّة في لغة Kotlin.]
+
*[http://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/to-list.html صفحة الدالة text.toCollection()‎ في التوثيق الرسميّ للمكتبة القياسيّة في لغة Kotlin.]
 
[[تصنيف:Kotlin]]
 
[[تصنيف:Kotlin]]
 
[[تصنيف:Kotlin Method]]
 
[[تصنيف:Kotlin Method]]

مراجعة 17:12، 13 يوليو 2018

تضيف الدالة toList()لائحة تحتوي كل حروف سلسلة الحروف  التي استٌدعيت عبرها.

البنية العامة

fun CharSequence.toList(): List<Char>

القيم المعادة

لائحة من الحروف.

أمثلة

استخدام الدالة toCollection()‎ مع السلاسل النصية

تستدعي الشيفرة الآتية الدالة toCharArray()‎ عبر عدة سلاسل نصية، وتطبع الناتج:

fun main(args: Array<String>) {
    println("Hello, world!".toList()) // [H, e, l, l, o, ,,  , w, o, r, l, d, !]
    println("Hsoub".toList()) // [H, s, o, u, b]
    println("114".toList()) // [1, 1, 4]
}

انظر أيضًا

  • toDouble()‎ : تحلّل الدالة toDouble()‎ السلسلة النصية التي استٌدعيت عبرها وتحوّلها إلى عدد من النوع Double وتعيد الناتج.
  • toUpperCase()‎ : تحوّل الدالة toUpperCase()‎ الحرف أو السلسلة النصية التي استٌدعيت عبرها إلى حالة الأحرف الكبيرة (uppercase).
  • isDefined(): تعيد القيمة true في حال كان الحرف (Unicode code point) الذي استٌدعيت عبره مُعرّفًا في اليونيكود (Unicode).

مصادر