AR/Table: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 35: Line 35:




<section name="Example" class="both" show="true">
<syntaxhighlight lang="lua">
t = { 1,2,"three"; pi=3.14159, banana="yellow" }
test1 = table.foreachi(t,print)
1      1
2      2
3      three


</syntaxhighlight> </section>




Line 62: Line 74:
  k = { apple="green", orange="orange", banana="yellow" }
  k = { apple="green", orange="orange", banana="yellow" }


test1 = table.foreachi(k,print)
test1 = table.foreach(k,print)




Line 72: Line 84:


</syntaxhighlight> </section>
</syntaxhighlight> </section>
<section name="Example" class="both" show="true">
<syntaxhighlight lang="lua">
t = { 1,2,"three"; pi=3.14159, banana="yellow" }
test1 = table.foreach(t,print)
1      1
2      2
3      three
pi      3.14159
banana  yellow
</syntaxhighlight> </section>





Revision as of 05:22, 26 August 2012

بسم الله الرحمن الرحيم




___________________________________________________________________


table.foreachi

 تستخدم ل إظهار الجدول  بصف واحد              
table   table.foreachi(table,function)


Click to collapse [-]
Example

 t = {1,1,2,3,5,8,13}

test1 = table.foreachi(t,print)


1 1
2 1
3 2
4 3
5 5
6 8
7 13


Click to collapse [-]
Example

 t = { 1,2,"three"; pi=3.14159, banana="yellow" }

test1 = table.foreachi(t,print)


1       1
2       2
3       three



___________________________________________________________________


table.foreach

تستخدم ل تكرار المفاتيح في الجدول
 


table table.foreach(table,function)


Click to collapse [-]
Example

 k = { apple="green", orange="orange", banana="yellow" }

test1 = table.foreach(k,print)




apple green
orange orange
banana yellow



Click to collapse [-]
Example

 t = { 1,2,"three"; pi=3.14159, banana="yellow" }

test1 = table.foreach(t,print)

1       1
2       2
3       three
pi      3.14159
banana  yellow










؟ table.foreachi و table.foreach الفرق بين

الاولى تستخدم لفهرسة الجدول بينما الاخرى هي لتكرار مفاتيح الجداول ,, ملاحظة : الثانيه غير مضمونه بما يتعلق الترتيب التي يتم تخزين مفاتيح في جدول



.