table.Flip

  table table.Flip( table input )

Açıklama

Bir tablonun içindeki her bir elemanın anahtar-değer çiftlerini ters çevirir, böylece her değer anahtar ve her anahtar da değer olur.

Bu fonksiyonu kullanırken dikkatli olun, çünkü bir Lua tablosu aynı anahtarın birden fazla örneğini içeremez. Bu nedenle, yinelenen değerlere sahip tablolarda bu fonksiyonu kullanırken veri kaybı yaşanabilir.
local test = { test = 1, test2 = 1 } local f = table.Flip( test ) PrintTable( f ) -- Çıktısı "1 = test2" olur

Argümanlar

1 table input
Elemanlarının ters çevrileceği tablo.

Döndürülen Değerler

1 table
Ters çevrilmiş tablo.

Örnek

local productIngredients = { "Cocoa Mass", "Cocoa Butter", "Vanilla", "Cocoa Solids: 70% min" } local flipped = table.Flip( productIngredients ) PrintTable( flipped )
Çıktı:
Cocoa Butter = 2 Cocoa Mass = 1 Cocoa Solids: 70% min = 4 Vanilla = 3

Tüm sunucular · GmodTR Launcher · Rehber · GMod Wiki · GmodTR nedir? · Sunucu ekle · Discord