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

من موسوعة حسوب
اذهب إلى التنقل اذهب إلى البحث
(أنشأ الصفحة ب'<noinclude>{{DISPLAYTITLE: التابع text.toHashSet()‎ في لغة Kotlin}}</noinclude> تحلّل الدالة <code>toHashSet()</code>‎ Kotlin/String|السل...')
 
ط
 
(3 مراجعات متوسطة بواسطة مستخدمين اثنين آخرين غير معروضة)
سطر 1: سطر 1:
<noinclude>{{DISPLAYTITLE: التابع text.toHashSet()‎ في لغة Kotlin}}</noinclude>
+
<noinclude>{{DISPLAYTITLE: الدالة <code>toHashSet()‎</code> في Kotlin}}</noinclude>
تحلّل الدالة <code>toHashSet()</code>‎ [[Kotlin/String|السلسلة النصية]] التي استٌدعيت عبرها وتحوّلها إلى عدد من النوع <code>[[Kotlin/Float/index|Float]]</code> وتعيد الناتج.
+
تعيد الدالة <code>toHashSet()</code>‎ كائنًا من النوع <code>HashSet</code> يحوي كل محارف [[Kotlin/CharSequence/index|السلسلة]] التي استٌدعيت معها.
 
 
في حال لم تكن  [[Kotlin/String|السلسلة النصية]] تمثل عددًا فستطلق الدالةُ استثناءً <code>NumberFormatException</code>.
 
  
 
== البنية العامة ==
 
== البنية العامة ==
 
<syntaxhighlight lang="kotlin">
 
<syntaxhighlight lang="kotlin">
inline actual fun String.toFloat(): Float
+
fun CharSequence.toHashSet(): HashSet<Char>
 
 
</syntaxhighlight>يُلاحَظ وجود الكلمة المفتاحية <code>inline</code> للدلالة على أن هذه الدالة مباشرة، وللمزيد من التفاصيل راجع <nowiki/>[[Kotlin/inline functions|توثيق الدوال المباشرة (inline functions)]].
 
  
 +
</syntaxhighlight>
 
== القيم المعادة ==
 
== القيم المعادة ==
عدد من النوع <code>[[Kotlin/Float/index|Float]]</code>.
+
يعاد كائن من النوع <code>HashSet</code> يحوي كل محارف [[Kotlin/CharSequence/index|السلسلة]] المعطاة.
  
 
== أمثلة ==
 
== أمثلة ==
 
+
مثالٌ<nowiki/> على استعمال الدالة <code>toHashSet()‎</code>:<syntaxhighlight lang="kotlin">
=== استخدام الدالة <code>toHashSet()‎</code> مع سلسلة نصية ===
 
الشيفرة الآتية <nowiki/>تستدعي الدالة <code>toHashSet()‎</code> عبر عدة  [[Kotlin/String|سلاسل نصية]]، وتطبع الناتج:<syntaxhighlight lang="kotlin">
 
fun main(args: Array<String>) {
 
        println("43.1f".toFloat()) // 43.1
 
        println("32.87".toFloat()) // 32.87
 
        println("0.32f".toFloat()) // 0.32
 
}
 
</syntaxhighlight>
 
=== استخدام الدالة <code>toFloat()‎</code> مع سلسلة نصية: الحالة الثانية ===
 
الشيفرة الآتية تستدعي الدالة <code>toFloat()‎</code> عبر [[Kotlin/String|سلسلة نصية]] غير صالحة:<syntaxhighlight lang="kotlin">
 
 
fun main(args: Array<String>) {
 
fun main(args: Array<String>) {
         println("43.1ff".toFloat()) // إطلاق استثناء
+
         println("hsoub".toHashSet()) // [h, b, s, u, o]
 +
        println("32.87".toHashSet()) // [8, 2, 3, ., 7]
 +
        println("wiki".toHashSet()) // [i, k, w]
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 
== انظر أيضًا ==
 
== انظر أيضًا ==
* <code>[[Kotlin/text/toUpperCase|toUpperCase()]]</code>‎ : تحوّل الدالة <code>toUpperCase()</code>‎ الحرف أو السلسلة النصية التي استٌدعيت عبرها إلى حالة الأحرف الكبيرة (uppercase).
+
*الدالة [[Kotlin/kotlin.text/toBoolean|<code>toBoolean()</code>‎]]: تعيد القيمة <code>true</code> إن كانت [[Kotlin/String|السلسلة النصية]] التي استٌدعيت معها تساوي <code>"true"</code> مع تجاهل حالة الأحرف، أو تعيد القيمة <code>false</code>.
* <code>[[Kotlin/kotlin.text/toDouble|toDouble()]]</code>‎ : تحلّل الدالة <code>toDouble()</code>‎ السلسلة النصية التي استٌدعيت عبرها وتحوّلها إلى عدد من النوع <code>Double</code> وتعيد الناتج.
+
*الدالة [[Kotlin/kotlin.text/toByteArray|<code>toByteArray()</code>‎]]: ترمز جميع محارف [[Kotlin/String|السلسلة النصية]] التي استٌدعيت معها وفقًا لترميز محدد ثم تضع الناتج في مصفوفة من النوع <code>[[Kotlin/ByteArray|ByteArray]]</code>.
 
+
*الدالة [[Kotlin/kotlin.text/toCharArray|<code>toCharArray()</code>‎]]: تضع جميع محارف [[Kotlin/String|السلسلة النصية]] التي استٌدعيت معها في مصفوفة من النوع <code>[[Kotlin/CharArray|CharArray]]</code>، إذ يوضع كل محرف في عنصر.
*<code>[[Kotlin/text/isDefined|toBigDecimalOrNull()]]</code>: تحلّل الدالة <code>toBigDecimalOrNull()</code>‎ [[Kotlin/String|السلسلة النصية]] التي استٌدعيت عبرها وتحوّلها إلى عدد من النوع <code>BigDecimal</code>.
+
*الدالة <nowiki/>[[Kotlin/kotlin.text/toCollection|<code>toCollection()</code>‎]]: تضيف كل محارف <nowiki/>[[Kotlin/CharSequence|السلسلة]] التي استٌدعيت معها إلى المجموعة المتغيرة المُمرّرة إليها.
*<code>[[Kotlin/kotlin.text/toBigDecimal|toBigDecimal()]]‎</code>: تحلّل الدالة <code>toBigDecimal()</code>‎ [[Kotlin/String|السلسلة النصية]] التي استٌدعيت عبرها وتحوّلها إلى عدد من النوع <code>BigDecimal</code>.
+
*الدالة [[Kotlin/kotlin.text/toList|<code>toList()</code>‎]]: تضيف كل محارف [[Kotlin/CharSequence|سلسلة المحارف]] التي استٌدعيت معها إلى [[Kotlin/collections/List|قائمة]]، إذ يوضع كل محرف في عنصر.
 
+
*الدالة [[Kotlin/text/toLowerCase|<code>toLowerCase()</code>‎]]: تحول [[Kotlin/Char|المحرف]] أو جميع محارف [[Kotlin/String|السلسلة النصية]] التي استٌدعيت معها إلى محارف صغيرة (lowercase).
* <code>[[Kotlin/text/isDefined|isDefined()]]‎</code>: تعيد القيمة <code>true</code> في حال كان الحرف (Unicode code point) الذي استٌدعيت عبره مُعرّفًا في اليونيكود (Unicode).toFloat
+
*الدالة [[Kotlin/kotlin.text/toMutableList|<code>toMutableList()</code>‎]]: تضيف كل محارف [[Kotlin/CharSequence|سلسلة المحارف]] التي استٌدعيت معها إلى [[Kotlin/collections/List|قائمة متغيرة]]، إذ يوضع كل محرف في عنصر.
 
+
*الدالة [[Kotlin/kotlin.text/toPattern|<code>toPattern()</code>‎]]: تحول [[Kotlin/String|السلسلة النصية]] التي استٌدعيت معها إلى نمط.
 +
*الدالة [[Kotlin/kotlin.text/toRegex|<code>toRegex()</code>‎]]: تحول [[Kotlin/String|السلسلة النصية]] التي استٌدعيت معها إلى [[Kotlin/kotlin.text/Regex/index|تعبير نمطي]] (regular expression). 
 +
*الدالة [[Kotlin/kotlin.text/toSet|<code>toSet()</code>‎]]: تضيف كل محارف [[Kotlin/CharSequence/index|سلسلة الحروف]]  التي استٌدعيت معها إلى مجموعة من النوع <code>[[Kotlin/Set|Set]]</code>، إذ يوضع كل محرف في عنصر.
 +
*الدالة [[Kotlin/kotlin.text/toSortedSet|<code>toSortedSet()</code>‎]]: تضيف كل محارف [[Kotlin/CharSequence|السلسلة]]  التي استٌدعيت معها إلى مجموعة من النوع <code>[[Kotlin/collections/SortedSet|SortedSet]]</code>، إذ يوضع كل محرف في عنصر.
 +
*الدالة [[Kotlin/kotlin.text/toString|<code>toString()</code>‎]] : تحول العدد الذي استٌدعي معها وفقًا لأساس مُحدّد إلى [[Kotlin/String|سلسلة نصية]].
 
== مصادر ==
 
== مصادر ==
* [http://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/to-float.html صفحة الدالة text.toHashSet()‎ في التوثيق الرسميّ للمكتبة القياسيّة في لغة Kotlin.]
+
* [http://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/to-hash-set.html صفحة الدالة toHashSet()‎ في التوثيق الرسميّ للمكتبة القياسيّة في لغة Kotlin.]
 
[[تصنيف:Kotlin]]
 
[[تصنيف:Kotlin]]
[[تصنيف:Kotlin Method]]
+
[[تصنيف:Kotlin Function]]
 +
[[تصنيف:Kotlin Text]]

المراجعة الحالية بتاريخ 11:42، 6 سبتمبر 2018

تعيد الدالة toHashSet()‎ كائنًا من النوع HashSet يحوي كل محارف السلسلة التي استٌدعيت معها.

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

fun CharSequence.toHashSet(): HashSet<Char>

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

يعاد كائن من النوع HashSet يحوي كل محارف السلسلة المعطاة.

أمثلة

مثالٌ على استعمال الدالة toHashSet()‎:

fun main(args: Array<String>) {
        println("hsoub".toHashSet()) // [h, b, s, u, o]
        println("32.87".toHashSet()) // [8, 2, 3, ., 7]
        println("wiki".toHashSet()) // [i, k, w]
}

انظر أيضًا

مصادر