AR/table.flip: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
(Blanked the page)
Tags: Blanking Reverted
Line 1: Line 1:
{{Useful Function}} __NOTOC__
<lowercasetitle></lowercasetitle>
هذه الوظيفة تقوم بإرجاع الجدول بالقيم من اخر قيمه لاول قيمه مثل الانعكاس


==Syntax==
<syntaxhighlight lang="lua">table table.flip( table theTable )</syntaxhighlight>
===Required Arguments===
* '''theTable''': الجدول الذى تريد انعكاس قيمه.
===Returns===
إرجاع الجدول بالقيم من اخر الجدول إلى اول الجدول.
==Code==
<section name="Shared" class="both" show="true">
<syntaxhighlight lang="lua">
function table.flip(theTable)
    assert(type(theTable) == "table", "Bad argument @ 'table.flip' [Expected table at argument 1, got "..(type(theTable)).."]")
    local newTable = {}
    for i = 1, #theTable do
        newTable[i] = theTable[#theTable-(i-1)]
    end
    return newTable
end
</syntaxhighlight>
</section>
'''المؤلف:''' [[User:IManGaaX|Youssef Maged (iManGaaX)]]
==Example==
<section name="Shared" class="both" show="true">
<syntaxhighlight lang="lua">
local myTable = {"test_1", "test_2", "test_3", "test_4", "test_5"}
for k, v in ipairs(myTable) do
    outputChatBox(v)
end
--// النتيجة سوف تكون
--// test_1
--// test_2
--// test_3
--// test_4
--// test_5
local flipedTable = table.flip(myTable)
for k, v in ipairs(flipedTable) do
    outputChatBox(v)
end
--// النتيجة سوف تكون
--// test_5
--// test_4
--// test_3
--// test_2
--// test_1
</syntaxhighlight>
</section>
==See Also==
{{Useful_Functions}}
[[en:table.flip]]

Revision as of 05:41, 9 October 2023