Nous n’avons pas trouvé cette entrée. Affichage de résultats approximatifs. Vérifiez l’orthographe ou proposez d’ajouter ce terme au dictionnaire.
array
Swift te lasă să faci downcasting în bucla array-ului, ceea ce în cazul acesta ar fi mult mai eficient.
Swift lets you downcast as part of the array loop, which in this case would be more efficient.
Observați că setăm 0 ca parametru al array-ului, deoarece păstrăm secvența de valori într-un array și după cum deja știm, numărarea elementelor de array începe de la 0.
Notice that as a parameter of the array we give 0 because we keep the sequence of values in an array, and as we already know, counting of array elements starts from 0.
Acest lucru înseamnă că singurul element al array-ului nostru se află la locația identificată prin indexul 0, și încercarea accesării locației cu indexul 1 va genera o eroare, pentru că nu există un indice 1 într-un array cu un singur element.
This means that our single element array resides at the location identified by index 0, and trying to access the location with index 1 will generate an error, because there is no index 1 in an array with a single element.
Dacă vă amintiți lecția precedentă, am comparat un array cu o clădire, în care avem apartamente (elementele array-ului), fiecare fiind identificat printr-un număr de apartament (index, sau indice).
If you remember our previous lesson, we compared an array to a building, where we have apartments (array's elements), each identified by an apartment number (index, or indices).
Vă puteți imagina această matrice ca o clădire (array-ul în sine), cu 5 apartamente (elementele array-ului) identificate printr-un număr de apartament (indicele).
You can imagine this array as a building (the array itself), with 5 apartments (the array's elements) identified by an apartment number (the index).
Deoarece în exemplul de mai sus am adăugat și un Caine pe a doua poziție a array-ului, programul a generat o eroare atunci când am folosit bucla foreach sub forma de Pisica.
Because in the above example we also added a Dog on the second position of the array, the program crashed when we used the foreach loop in the form of Cat.
Acesta este similar cu CopyTo(), dar oferă noua referință a array-ului.
This is similar to CopyTo(), but it provides the new array reference.
În acest moment valoarea variabilei pozitieCurenta devine negativă (deoarece prima poziție a array-ului este 0) și terminăm execuția metodei folosind operatorul return.
In this moment the value of the variable currentPosition becomes negative (as the first position of the array is 0) and we end the execution of the method using the operator return.
Deci, cum am putut să adaug o Pisica pe prima poziție a array-ului de tip Animal și apoi să adaug un Caine pe a doua poziție?
So, how was I able to add a Cat on the first position of the array of type Animal, and then, add a Dog on the second position?
Acest lucru se întâmplă deoarece memoria pentru elementele array-ului nu este încă alocată.
This happens because the memory for the elements is not yet allocated.
Această logică este necesară atunci când mărimea array-ului este inadecvată.
This logic is needed when an array's size is inadequate.
Inițial, enumeratorul indică spre o valoare santinelă, o celulă de la începutul array-ului, care nu există cu adevărat și nu are nicio valoare.
Initially, the enumerator points to a sentinel value, a cell at the beginning of the array that does not really exist and has no value.
Când dorim să obținem un enumerator pe acel bloc de elemente, obținem în esență un obiect care face referire la o valoare santinelă de la începutul array-ului, o valoare care nu există de fapt.
When we want to get an enumerator over that block of elements, we essentially get an object that references a sentinel value at the beginning of the array, a value that doesn't actually exist.
Contenu potentiellement sensible ou inapproprié
Les exemples vous aident à traduire le mot ou l’expression cherchés dans des contextes variés. Ils ne sont ni sélectionnés ni validés par nous et peuvent contenir des mots ou des idées inappropriés. Signalez des exemples à modifier ou à retirer. Les traductions potentiellement sensibles, inappropriées ou familières sont généralement marquées de rouge ou d’orange.