الفرق بين المراجعتين ل"Kotlin/ranges/until"

من موسوعة حسوب
< Kotlin‏ | ranges
اذهب إلى التنقل اذهب إلى البحث
(أنشأ الصفحة ب'<noinclude>{{DISPLAYTITLE: الثابتة <code>‎ranges.until()‎</code> في لغة Kotlin}}</noinclude> تعيد الدالة ‎<code>until()‎</code> مجالا...')
 
سطر 1: سطر 1:
<noinclude>{{DISPLAYTITLE: الثابتة <code>‎ranges.until()‎</code> في لغة Kotlin}}</noinclude>
+
<noinclude>{{DISPLAYTITLE: الثابتة <code>‎until()‎</code> في لغة Kotlin}}</noinclude>
 
تعيد الدالة ‎<code>until()‎</code> مجالا متدرّجًا (progression) تنازليًا من القيمة التي استُدعيت عبرها وحتى القيمة الممرّرة. ينبغي أن تكون القيمة الممررة أصغر من القيمة التي استُدعيت عبرها الدالة، وإلّا ستعيد الدالة مجالا متدرجا فارغًا.
 
تعيد الدالة ‎<code>until()‎</code> مجالا متدرّجًا (progression) تنازليًا من القيمة التي استُدعيت عبرها وحتى القيمة الممرّرة. ينبغي أن تكون القيمة الممررة أصغر من القيمة التي استُدعيت عبرها الدالة، وإلّا ستعيد الدالة مجالا متدرجا فارغًا.
 
==البنية العامة==
 
==البنية العامة==

مراجعة 18:16، 2 يوليو 2018

تعيد الدالة ‎until()‎ مجالا متدرّجًا (progression) تنازليًا من القيمة التي استُدعيت عبرها وحتى القيمة الممرّرة. ينبغي أن تكون القيمة الممررة أصغر من القيمة التي استُدعيت عبرها الدالة، وإلّا ستعيد الدالة مجالا متدرجا فارغًا.

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

infix fun Int.downTo(to: Byte): IntProgression 
infix fun Long.downTo(to: Byte): LongProgression 
infix fun Byte.downTo(to: Byte): IntProgression 
infix fun Short.downTo(to: Byte): IntProgression 
infix fun Char.downTo(to: Char): CharProgression 
infix fun Int.downTo(to: Int): IntProgression 
infix fun Long.downTo(to: Int): LongProgression 
infix fun Byte.downTo(to: Int): IntProgression 
infix fun Short.downTo(to: Int): IntProgression
infix fun Int.downTo(to: Long): LongProgression 
infix fun Long.downTo(to: Long): LongProgression 
infix fun Byte.downTo(to: Long): LongProgression 
infix fun Short.downTo(to: Long): LongProgression 
infix fun Int.downTo(to: Short): IntProgression 
infix fun Long.downTo(to: Short): LongProgression 
infix fun Byte.downTo(to: Short): IntProgression 
infix fun Short.downTo(to: Short): IntProgression

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

مجال متدرّج (progression) تنازلي.

مثال

استخدام الدالة until()‎

في الشيفرة التالية نعرّف عددين x و y، ثم نعرّف مجال متدرّج p عبر استدعاء الدالةuntil()‎ عبر x ونمرر إليها الوسيط y ، ثم نستخدم p في حلقة for:

fun main(args: Array<String>) {    
    val x = 9 
    val y = 4
    val p = x.downTo(y) 
    
    for (a in p) print(a) // 987654
}

أنظر أيضًا

  • الثابتةcategory‎ : تساوي القيمة القصوى لبديل وحدة اليونيكود (Unicode surrogate code unit).

مصادر